<?php

namespace App\Models\Tms;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Auth;

class TmsRequestion extends Model
{
     use HasFactory;

    protected $guarded = [];

    // public function entryby(){
    //     return $this->belongsTo('App\Models\User','enteredbyid');
    // }

    public function request_items(){
        return $this->hasMany('App\Models\Tms\TmsRequestionItem','requestion_id');
    }

    protected static function boot()
    {
        parent::boot();

        TmsRequestion::creating(function($model) {
            $user = Auth::user();
            if($user!=null){
                $model->enteredbyid = $user->id;
                // $model->organisation_id = $user->active_organisation;
            }
        });
    }
}
