<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Spatie\Activitylog\Traits\LogsActivity;
use Spatie\Activitylog\LogOptions;

class LeaveRequest extends Model
{
    use HasFactory;

    protected $guarded = [];


    use LogsActivity;

    public function getActivitylogOptions(): LogOptions
    {
        return LogOptions::defaults()
            ->logAll()
            ->useLogName('LeaveRequest')
            ->logOnlyDirty()
            ->setDescriptionForEvent(fn(string $eventName) => "Leave request '{$this->id}' has been {$eventName}")
            ->dontSubmitEmptyLogs();
    }



    public function user()
    {
        return $this->belongsTo(User::class, "user_id");
    }

    public function organisation()
    {
        return $this->belongsTo(Organisation::class, "organisation_id");
    }
}
