<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class EmployeeProfile extends BaseModel
{
    /** @use HasFactory<\Database\Factories\EmployeeProfileFactory> */
    protected $fillable = [
        'user_id',
        'phone',
        'personal_email',
        'personal_phone',
        'date_of_birth',
        'address',
        'city',
        'job_title',
        'department',
        'department_id',
        'manager_id',
        'joining_date',
        'emergency_contact_name',
        'emergency_contact_phone',
        'id_card_path',
        'contract_path',
        'tax_form_path',
    ];

    protected function casts(): array
    {
        return [
            'joining_date' => 'date',
            'date_of_birth' => 'date',
        ];
    }

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

    public function departmentRel(): BelongsTo
    {
        return $this->belongsTo(Department::class, 'department_id');
    }

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