*/ protected $fillable = [ 'employee_id', 'type', 'status', 'start_date', 'end_date', 'reason', 'notes', 'approved_by', 'approved_at', ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'start_date' => 'date', 'end_date' => 'date', 'approved_at' => 'datetime', 'created_at' => 'datetime', 'updated_at' => 'datetime', ]; public function employee(): BelongsTo { return $this->belongsTo(Employee::class); } public function approver(): BelongsTo { return $this->belongsTo(User::class, 'approved_by'); } public function histories(): HasMany { return $this->hasMany(LeaveHistory::class)->orderByDesc('changed_at'); } }