<?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 PayGroup extends Model
{
    use HasFactory;

    protected $guarded = [];

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

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