Skip to main content

Practice Another CRUD: Task Categories

Premium
10 min read

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 -m
php 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();
});

The Full Lesson is Only for Premium Members

Want to access all of our courses? (30 h 09 min)

You also get:

55 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

YC
Yohn Cheung ✓ Link copied!

When you have created the files for the database, dont forget: "php artisan migrate"

GA
GIUSEPPE ALESSANDRO DE BLASIO ✓ Link copied!

In resources/js/pages/TaskCategories/Index.vue the import of toast "import { toast } from 'sonner';" fails I think it is "import { toast } from 'vue-sonner';"

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.