<?php

namespace App\Models;

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

class OrganisationTaxSetting extends Model
{
    use HasFactory;

    protected $fillable = [
        "org_id",
        "salary_range",
        "percentage"
    ];


    use LogsActivity;

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

    //Define Parent Relationships
    public function organisationTaxEmployee()
    {

        return $this->hasMany(OrganisationTaxEmployee::class);
    }
    //Define Child Relationships
    public function organisation()
    {
        return $this->belongsTo(Organisation::class, "org_id");
    }
}
