<?php

namespace App\Modules\HR\Employees\Models;

use App\Models\User;
use App\Modules\HR\Employees\Enums\EmployeeDocumentType;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class EmployeeDocument extends Model
{
    protected $fillable = [
        'employee_id',
        'type',
        'file_path',
        'expires_at',
        'uploaded_by',
    ];

    protected function casts(): array
    {
        return [
            'type' => EmployeeDocumentType::class,
            'expires_at' => 'date',
        ];
    }

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

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