﻿<?php

namespace App\Models;

use Illuminate\Support\Facades\Auth;
use App\Scopes\OrganisationScope;

use Illuminate\Database\Eloquent\Model;

class PayslipType extends Model
{
    protected $fillable = [
        'name',
        'created_by',
        'organisation_id',
    ];

    protected static function booted()
    {
        static::addGlobalScope(new OrganisationScope);

        static::creating(function ($model) {
            if (Auth::check()) {
                $model->organisation_id = Auth::user()->organisation_id;
            }
        });
    }