From dc2cc57b835f84a6ee587a208e2acf01f2e0c653 Mon Sep 17 00:00:00 2001 From: Michal Feher Date: Fri, 15 Nov 2024 14:47:31 +0100 Subject: [PATCH] no message --- be/app/Http/Resources/SubTaskResource.php | 41 ++++++++++--------- ...2024_11_15_133850_add_type_to_subtasks.php | 31 ++++++++++++++ 2 files changed, 52 insertions(+), 20 deletions(-) create mode 100644 be/database/migrations/2024_11_15_133850_add_type_to_subtasks.php diff --git a/be/app/Http/Resources/SubTaskResource.php b/be/app/Http/Resources/SubTaskResource.php index 147a3ff..ef74185 100644 --- a/be/app/Http/Resources/SubTaskResource.php +++ b/be/app/Http/Resources/SubTaskResource.php @@ -10,32 +10,33 @@ class SubTaskResource extends JsonResource * Transform the resource into an array. * * @param \Illuminate\Http\Request $request + * * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable */ public function toArray($request) { return [ - 'id' => $this->id, - 'created_by' => $this->created_by, - 'master_task' => $this->mastertask->title, + 'id' => $this->id, + 'type' => $this->type, + 'created_by' => $this->created_by, + 'master_task' => $this->mastertask->title, 'master_task_description' => $this->mastertask->description, - 'master_task_deadline' => $this->mastertask->deadline, - 'master_task_id' => $this->mastertask->id, - 'description' => $this->description, - 'project_code' => ($this->mastertask->project) ? $this->mastertask->project->code . ' ' . $this->mastertask->project->name : null, - 'title' => $this->title, - 'team_id' => ($this->mastertask->team) ? $this->mastertask->team->id : null, - 'team' => $this->mastertask->team, - 'employee_id' => $this->user->id, - 'duration' => $this->estimated_time, - 'spent_time' => $this->tracked_time, - 'deadline' => $this->deadline, - 'is_finished' => $this->is_finished, - 'timeblocks' => TimeblockResource::collection($this->timeblocks), - 'timesheets' => TimesheetResource::collection($this->timesheets), - 'files' => AttachmentResource::collection($this->attachments->isNotEmpty() ? $this->attachments : $this->mastertask->attachments), - 'color' => $this->mastertask->color, + 'master_task_deadline' => $this->mastertask->deadline, + 'master_task_id' => $this->mastertask->id, + 'description' => $this->description, + 'project_code' => ($this->mastertask->project) ? $this->mastertask->project->code . ' ' . $this->mastertask->project->name : null, + 'title' => $this->title, + 'team_id' => ($this->mastertask->team) ? $this->mastertask->team->id : null, + 'team' => $this->mastertask->team, + 'employee_id' => $this->user->id, + 'duration' => $this->estimated_time, + 'spent_time' => $this->tracked_time, + 'deadline' => $this->deadline, + 'is_finished' => $this->is_finished, + 'timeblocks' => TimeblockResource::collection($this->timeblocks), + 'timesheets' => TimesheetResource::collection($this->timesheets), + 'files' => AttachmentResource::collection($this->attachments->isNotEmpty() ? $this->attachments : $this->mastertask->attachments), + 'color' => $this->mastertask->color, ]; - } } diff --git a/be/database/migrations/2024_11_15_133850_add_type_to_subtasks.php b/be/database/migrations/2024_11_15_133850_add_type_to_subtasks.php new file mode 100644 index 0000000..070ff4a --- /dev/null +++ b/be/database/migrations/2024_11_15_133850_add_type_to_subtasks.php @@ -0,0 +1,31 @@ +string('type')->after('master_task_id')->default('sub_task'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('subtasks', function (Blueprint $table) { + // + }); + } +};