diff --git a/Modules/PMS/app/Http/Controllers/TaskController.php b/Modules/PMS/app/Http/Controllers/TaskController.php index f8ae197..57490f1 100644 --- a/Modules/PMS/app/Http/Controllers/TaskController.php +++ b/Modules/PMS/app/Http/Controllers/TaskController.php @@ -42,6 +42,7 @@ class TaskController extends Controller { $data['title'] = 'Create Task'; $data['status'] = Task::STATUS; + $data['priority'] = Task::PRIORITY; $data['categoryList'] = Task::CATEGORY; $data['projectList'] = $this->projectRepository->pluck(); $data['memberList'] = $this->employeeRepository->pluck(); @@ -83,6 +84,7 @@ class TaskController extends Controller $data['title'] = 'Edit Task'; $data['task'] = $this->taskRepository->getTaskById($id); $data['status'] = Task::STATUS; + $data['priority'] = Task::PRIORITY; $data['categoryList'] = Task::CATEGORY; $data['projectList'] = $this->projectRepository->pluck(); $data['memberList'] = $this->employeeRepository->pluck(); diff --git a/Modules/PMS/app/Models/Project.php b/Modules/PMS/app/Models/Project.php index d67ad99..4b52015 100644 --- a/Modules/PMS/app/Models/Project.php +++ b/Modules/PMS/app/Models/Project.php @@ -5,6 +5,7 @@ namespace Modules\PMS\Models; use App\Traits\CreatedUpdatedBy; use App\Traits\StatusTrait; use Illuminate\Database\Eloquent\Model; +use Modules\Employee\Models\Employee; class Project extends Model { @@ -19,4 +20,14 @@ class Project extends Model 11 => 'Laravel', ]; + public function client() + { + return $this->belongsTo(Client::class, 'client_id'); + } + + public function members() + { + return $this->belongsTo(Employee::class, 'members_id'); + } + } diff --git a/Modules/PMS/app/Models/Task.php b/Modules/PMS/app/Models/Task.php index 4faf2eb..53342b4 100644 --- a/Modules/PMS/app/Models/Task.php +++ b/Modules/PMS/app/Models/Task.php @@ -4,7 +4,9 @@ namespace Modules\PMS\Models; use App\Traits\CreatedUpdatedBy; use App\Traits\StatusTrait; +use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Model; +use Modules\Employee\Models\Employee; class Task extends Model { @@ -12,11 +14,50 @@ class Task extends Model protected $table = 'tbl_tasks'; protected $guarded = []; - protected $appends = ['status_name']; + protected $appends = ['status_name', 'priority_status']; const CATEGORY = [ 10 => 'Vue', 11 => 'Laravel', ]; + const PRIORITY = [ + 10 => 'High', + 11 => 'Meduim', + 12 => 'Low', + ]; + + 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'); + } + } diff --git a/Modules/PMS/resources/views/project/index.blade.php b/Modules/PMS/resources/views/project/index.blade.php index ad43add..708bbcf 100644 --- a/Modules/PMS/resources/views/project/index.blade.php +++ b/Modules/PMS/resources/views/project/index.blade.php @@ -39,7 +39,7 @@ {{ $project->members_id }} {{ $project->start_date }} {{ $project->end_date }} - {{ $project->client_id }} + {{ optional($project->client)->client_name }} {!! $project->status_name !!}
diff --git a/Modules/PMS/resources/views/task/index.blade.php b/Modules/PMS/resources/views/task/index.blade.php index 081a894..8ef6d7b 100644 --- a/Modules/PMS/resources/views/task/index.blade.php +++ b/Modules/PMS/resources/views/task/index.blade.php @@ -37,11 +37,11 @@ {{ $key + 1 }} {{ $task->title }} {{ $task->task_category_id }} - {{ $task->project_id }} + {{ optional($task->project)->project_name }} {{ $task->start_date }} {{ $task->due_date }} - {{ $task->assigned_id }} - {{ $task->priority }} + {{ optional($task->assigned)->full_name }} + {!! $task->priority_status !!} {!! $task->status_name !!}
diff --git a/Modules/PMS/resources/views/task/partials/action.blade.php b/Modules/PMS/resources/views/task/partials/action.blade.php index 3b0dafd..066a0d4 100644 --- a/Modules/PMS/resources/views/task/partials/action.blade.php +++ b/Modules/PMS/resources/views/task/partials/action.blade.php @@ -72,7 +72,7 @@
{{ html()->label('Priority')->class('form-label') }} - {{ html()->select('priority', $status)->class('form-control')->required() }} + {{ html()->select('priority', $priority)->class('form-control')->required() }}