'Pending',
11 => 'Approved',
12 => 'Rejected',
];
const PRIORITY = [
10 => 'High',
11 => 'Meduim',
12 => 'Low',
];
const TICKET_TYPE = [
11 => 'Management',
12 => 'Boxes',
13 => 'Assets'
];
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,
);
}
protected function ticketType(): Attribute
{
return Attribute::make(
get: function (mixed $value, array $attributes) {
switch ($attributes['ticket_type']) {
case '11':
return '' . self::TICKET_TYPE[$attributes['ticket_type']] . '';
break;
case '12':
return '' . self::TICKET_TYPE[$attributes['ticket_type']] . '';
break;
case '13':
return '' . self::TICKET_TYPE[$attributes['ticket_type']] . '';
break;
default:
# code...
break;
}
},
set: fn($value) => $value,
);
}
public function project()
{
return $this->belongsTo(Project::class, 'project_id');
}
public function employee()
{
return $this->belongsTo(Employee::class, 'employee_id');
}
public function department()
{
return $this->belongsTo(Department::class, 'department_id')->withDefault();
}
public function documents(): MorphMany
{
return $this->morphMany(Document::class, 'documentable');
}
public function comments()
{
return $this->morphMany(Comment::class, 'commentable');
}
}