'Pending', 2 => 'Approved', 3 => 'Rejected', ]; const DURATION = [ 1 => 'Full Day', 2 => 'Half Day', 3 => 'Multiple', ]; protected static function booted(): void { static::addGlobalScope(new CreatedByScope); } protected function statusName(): Attribute { return Attribute::make( get: function (mixed $value, array $attributes) { switch ($attributes['status']) { case '1': $color = 'dark'; break; case '2': $color = 'success'; break; case '3': $color = 'danger'; break; default: $color = 'light'; break; } return collect([ 'status' => self::PROGRESS_STATUS[$attributes['status']], 'color' => $color]); }, set: fn($value) => $value, ); } public function getDuration() { return self::DURATION[$this->duration] ?? null; } public function employee() { return $this->belongsTo(Employee::class, 'employee_id'); } public function leaveType() { return $this->belongsTo(LeaveType::class, 'leave_type_id'); } }