<?php

namespace App\Modules\HR\Offboarding\Models;

use App\Modules\Admin\Tenancy\Traits\BelongsToTenant;
use App\Modules\HR\Employees\Models\Employee;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class OffboardingCase extends Model
{
    use BelongsToTenant;

    protected $table = 'hr_offboarding_cases';

    protected $guarded = ['id'];

    protected function casts(): array
    {
        return ['last_working_date' => 'date', 'experience_letter_issued' => 'boolean', 'deactivated_user_at' => 'datetime'];
    }

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

    public function checklistItems(): HasMany
    {
        return $this->hasMany(OffboardingChecklistItem::class, 'case_id');
    }
}
