diff --git a/Modules/Category/Http/Requests/CategoryUpdateRequest.php b/Modules/Category/Http/Requests/CategoryUpdateRequest.php index 8bf895e..2723601 100644 --- a/Modules/Category/Http/Requests/CategoryUpdateRequest.php +++ b/Modules/Category/Http/Requests/CategoryUpdateRequest.php @@ -30,7 +30,7 @@ public function rules(): array 'string', 'min:3', 'max:250', - Rule::unique('categories', 'title')->ignore($this->route()->parameter('category')), // TODO: Improve validation + Rule::unique('categories', 'title')->ignore($this->route()->parameter('category')), ], ]; } diff --git a/Modules/Common/helpers.php b/Modules/Common/helpers.php index 61c5e48..b3d9bbc 100644 --- a/Modules/Common/helpers.php +++ b/Modules/Common/helpers.php @@ -1,21 +1 @@ value; - } - - return $values; - } -} diff --git a/Modules/Task/Database/Migrations/2023_04_21_190126_create_tasks_table.php b/Modules/Task/Database/Migrations/2023_04_21_190126_create_tasks_table.php index 29a42be..52c6bfa 100644 --- a/Modules/Task/Database/Migrations/2023_04_21_190126_create_tasks_table.php +++ b/Modules/Task/Database/Migrations/2023_04_21_190126_create_tasks_table.php @@ -14,11 +14,13 @@ public function up(): void { Schema::create('tasks', function (Blueprint $table) { $table->id(); + $table->string('title'); + $table->string('priority'); + $table->string('status')->nullable(); + $table->longText('description'); $table->timestamp('remind_date')->nullable(); - $table->enum('priority', get_enum_values(TaskPriorityEnum::cases())); - $table->enum('status', get_enum_values(TaskStatusEnum::cases()))->nullable(); // TODO: Add label $table->timestamps(); }); diff --git a/Modules/Task/Http/Controllers/TaskController.php b/Modules/Task/Http/Controllers/TaskController.php index 018bf6d..60f6016 100644 --- a/Modules/Task/Http/Controllers/TaskController.php +++ b/Modules/Task/Http/Controllers/TaskController.php @@ -47,21 +47,20 @@ public function show(Task $task) /** * Update the specified resource in storage. */ - public function update(UpdateTaskRequest $request, Task $task) + public function update(UpdateTaskRequest $request, Task $task): \Illuminate\Http\JsonResponse { resolve(TaskService::class)->update($request->validated(), $task); return (new TaskResource($task)) ->response() - ->setStatusCode(202); // TODO: Refresh new task + ->setStatusCode(204); } /** * Remove the specified resource from storage. */ - public function destroy(Task $task) + public function destroy(Task $task): \Illuminate\Foundation\Application|\Illuminate\Http\Response|\Illuminate\Contracts\Routing\ResponseFactory { - // TODO: Add some condition $task->delete(); return response([], Response::HTTP_NO_CONTENT); diff --git a/Modules/Task/Http/Requests/StoreTaskRequest.php b/Modules/Task/Http/Requests/StoreTaskRequest.php index 207d532..7fc7198 100644 --- a/Modules/Task/Http/Requests/StoreTaskRequest.php +++ b/Modules/Task/Http/Requests/StoreTaskRequest.php @@ -19,15 +19,13 @@ public function authorize(): bool /** * Get the validation rules that apply to the request. - * - * @return array */ public function rules(): array { return [ 'title' => 'required|string|min:3|max:255', 'description' => 'required|string|min:3', - 'remind_date' => 'required|string', // TODO: ADD MORE RULES + 'remind_date' => 'required|string', 'priority' => ['required', 'string', new Enum(TaskPriorityEnum::class), 'max:250'], 'status' => ['required', 'string', new Enum(TaskStatusEnum::class), 'max:250'], ]; diff --git a/Modules/Task/Http/Requests/UpdateTaskRequest.php b/Modules/Task/Http/Requests/UpdateTaskRequest.php index 60e5b66..19c0b85 100644 --- a/Modules/Task/Http/Requests/UpdateTaskRequest.php +++ b/Modules/Task/Http/Requests/UpdateTaskRequest.php @@ -19,15 +19,13 @@ public function authorize(): bool /** * Get the validation rules that apply to the request. - * - * @return array */ public function rules(): array { return [ 'title' => 'required|string|min:3|max:255', 'description' => 'required|string|min:3', - 'remind_date' => 'required|string', // TODO: ADD MORE RULES + 'remind_date' => 'required|string', 'priority' => ['required', 'string', new Enum(TaskPriorityEnum::class), 'max:250'], 'status' => ['required', 'string', new Enum(TaskStatusEnum::class), 'max:250'], ]; diff --git a/Modules/Task/Models/Task.php b/Modules/Task/Models/Task.php index 858d58b..dfe9df3 100644 --- a/Modules/Task/Models/Task.php +++ b/Modules/Task/Models/Task.php @@ -11,19 +11,23 @@ class Task extends Model use HasFactory; /** - * Set factory. + * Fillable columns. * - * @return TaskFactory + * @var string[] */ - protected static function newFactory() - { - return TaskFactory::new(); - } + protected $fillable = [ + 'title', + 'description', + 'remind_date', + 'priority', + 'status' + ]; /** - * Fillable columns. - * - * @var string[] + * Set factory for model. */ - protected $fillable = ['title', 'description', 'remind_date', 'priority', 'status']; + protected static function newFactory(): TaskFactory + { + return TaskFactory::new(); + } }