<?php

namespace App\Models;

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

class BOMPickListEmployee extends Model
{
    use LogsActivity;

    protected $table = 'bom_pick_list_employees';

    protected $fillable = [
        'bom_pick_list_id',
        'employee_id',
        'is_checked',
        'notes',
        'assigned_by',
    ];

    protected $casts = [
        'is_checked' => 'boolean',
    ];

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

    public function employee(): BelongsTo
    {
        return $this->belongsTo(Account::class, 'employee_id');
    }

    public function assignedBy(): BelongsTo
    {
        return $this->belongsTo(User::class, 'assigned_by');
    }

    public function getActivitylogOptions(): LogOptions
    {
        return LogOptions::defaults()
            ->useLogName('bom_pick_list_employee')
            ->logFillable()
            ->logOnlyDirty()
            ->dontSubmitEmptyLogs();
    }
}
