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

    protected $fillable = [
        "type",
        "employee_contribution",
        "company_contribution",
        "org_id"
    ];

    use LogsActivity;

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


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