'Vue', 11 => 'Laravel', ]; const PRIORITY = [ 10 => 'High', 11 => 'Meduim', 12 => 'Low', ]; const STATUS = [ 10 => 'Incomplete', 11 => 'To DO', 12 => 'Doing', 13 => 'In Review', 14 => 'Completed', ]; protected $casts = [ 'assigned_id' => 'array', ]; protected function statusName(): Attribute { return Attribute::make( get: function (mixed $value, array $attributes) { switch ($attributes['status']) { case '10': $color = 'danger'; break; case '11': $color = 'info'; break; case '12': $color = 'primary'; break; case '13': $color = 'warning'; break; case '14': $color = 'success'; break; default: $color = 'light'; break; } return collect([ 'status' => self::STATUS[$attributes['status']], 'color' => $color]); }, set: fn($value) => $value, ); } protected function priorityStatus(): Attribute { return Attribute::make( get: function (mixed $value, array $attributes) { switch ($attributes['priority']) { case '10': return '' . self::PRIORITY[$attributes['priority']] . ''; break; case '11': return '' . self::PRIORITY[$attributes['priority']] . ''; break; case '12': return '' . self::PRIORITY[$attributes['priority']] . ''; break; default: # code... break; } }, set: fn($value) => $value, ); } public function project() { return $this->belongsTo(Project::class, 'project_id'); } public function assigned() { return $this->belongsTo(Employee::class, 'assigned_id'); } public function taskCategory() { return self::CATEGORY[$this->task_category_id ?? null]; } }