<?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 ExchangeRate extends Model
{
    use HasFactory;
    protected $table = "exchange_list";
    protected $guarded = [];

    use LogsActivity;

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


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