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

    protected $fillable = [
        "name",
        "address",
        "logo",
        "email",
    ];

    use LogsActivity;

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


    public function groupAccountOrganisation()
    {
        return $this->hasMany(GroupAccountOrganisation::class);
    }
}
