<?php

namespace App\Models\Hr;

use App\Models\User;
use App\Traits\BelongsToStore;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class LeaveRequest extends Model
{
    use BelongsToStore;

    protected $fillable = [
        'store_id', 'user_id', 'type', 'start_date', 'end_date',
        'days', 'reason', 'status', 'audit_user_id', 'audit_at',
    ];

    protected function casts(): array
    {
        return [
            'type' => 'integer',
            'status' => 'integer',
            'days' => 'decimal:1',
            'start_date' => 'date',
            'end_date' => 'date',
            'audit_at' => 'datetime',
        ];
    }

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

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