Let's practice creating a CRUD with another one: Task Categories. It will be almost the same as Tasks CRUD, so for the most part, I will just show the code and specify the differences.
Task Categories: DB Model/Migration
First, we prepare the back end.
Create Model, Migration, and Pivot table for task categories:
php artisan make:model TaskCategory -mphp artisan make:migration create_task_task_category_table
Migration:
Schema::create('task_categories', function (Blueprint $table) { $table->id(); $table->string('name'); $table->timestamps();});
Pivot migration:
Schema::create('task_task_category', function (Blueprint $table) { $table->foreignId('task_id')->constrained(); $table->foreignId('task_category_id')->constrained();});