<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class EmployeeAssignment extends Model
{
    use HasFactory;

    // Assignment type constants
    public const TYPE_KCD = 'kcd';
    public const TYPE_SCHOOL = 'school';

    protected $fillable = [
        'employee_id',
        'assignment_type',
        'kcd_id',
        'kab_kota_id',
        'school_id',
        'start_date',
        'end_date',
        'notes',
        'is_active'
    ];

    protected $casts = [
        'start_date' => 'date',
        'end_date' => 'date',
        'is_active' => 'boolean',
    ];

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

    public function kcd()
    {
        return $this->belongsTo(Kcd::class);
    }

    public function kabKota()
    {
        return $this->belongsTo(KabKota::class, 'kab_kota_id');
    }

    public function school()
    {
        return $this->belongsTo(School::class);
    }
}
