83 lines
1.9 KiB
PHP
83 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace Modules\ProfessionalProject\Entities;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class PpTask extends Model
|
|
{
|
|
protected $table = 'pp_tasks';
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
protected $casts = [
|
|
'start_date' => 'datetime',
|
|
'due_date' => 'datetime',
|
|
];
|
|
|
|
public function project()
|
|
{
|
|
return $this->belongsTo(PpProject::class, 'project_id');
|
|
}
|
|
|
|
public function milestone()
|
|
{
|
|
return $this->belongsTo(PpMilestone::class, 'milestone_id');
|
|
}
|
|
|
|
public function status()
|
|
{
|
|
return $this->belongsTo(PpTaskStatus::class, 'status_id');
|
|
}
|
|
|
|
public function assignees()
|
|
{
|
|
return $this->belongsToMany(\App\User::class, 'pp_task_assignees', 'task_id', 'user_id');
|
|
}
|
|
|
|
public function createdBy()
|
|
{
|
|
return $this->belongsTo(\App\User::class, 'created_by');
|
|
}
|
|
|
|
public function parent()
|
|
{
|
|
return $this->belongsTo(self::class, 'parent_id');
|
|
}
|
|
|
|
public function children()
|
|
{
|
|
return $this->hasMany(self::class, 'parent_id');
|
|
}
|
|
|
|
public function dependencies()
|
|
{
|
|
return $this->hasMany(PpTaskDependency::class, 'task_id');
|
|
}
|
|
|
|
public function blockers()
|
|
{
|
|
return $this->hasMany(PpTaskDependency::class, 'blocker_task_id');
|
|
}
|
|
|
|
public static function priorityDropdown()
|
|
{
|
|
return [
|
|
'low' => __('professionalproject::lang.priority_low'),
|
|
'normal' => __('professionalproject::lang.priority_normal'),
|
|
'high' => __('professionalproject::lang.priority_high'),
|
|
'urgent' => __('professionalproject::lang.priority_urgent'),
|
|
];
|
|
}
|
|
|
|
public static function priorityColors()
|
|
{
|
|
return [
|
|
'low' => 'bg-gray',
|
|
'normal' => 'bg-info',
|
|
'high' => 'bg-warning',
|
|
'urgent' => 'bg-danger',
|
|
];
|
|
}
|
|
}
|