<?php
namespace App\Modules\HR\Leave\Models;

use App\Modules\HR\Core\Models\Employee;
use App\Modules\HR\Core\Models\LeaveType;
use Illuminate\Database\Eloquent\Model;

class LeaveApplication extends Model
{
    protected $fillable = [
        'employee_id',
        'branch_id',
        'leave_type_id',
        'leave_mode',
        'from_date',
        'to_date',
        'from_time',
        'to_time',
        'first_half',
        'second_half',
        'prior_late',
        'approval_status',
        'remarks',
        'created_by',
    ];

    protected $casts = [
        'first_half' => 'boolean',
        'second_half' => 'boolean',
    ];

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

    public function leaveType()
    {
        return $this->belongsTo(LeaveType::class);
    }

    public function dates()
    {
        return $this->hasMany(LeaveApplicationDate::class);
    }
}
