Courses / Laravel PHP for Beginners: Build a Blog
Lesson 6 of 9

Creating the Post Model, Migration, and Controller

Video by Dani Krossing on YouTube · 12 min. We did not make this video and we do not host it — watching it here still counts as a view for the creator.

Use php artisan make:model Post -mcr to generate model, migration, and resource controller in one step. New developers sometimes forget the -c flag and end up writing a separate controller later. Add validation rules in the controller’s store method to prevent empty titles.

A well‑structured controller follows REST conventions: index, create, store, show, edit, update, destroy. This makes it easier for front‑end developers to consume your API later.

Start learning free

Sign in with WhatsApp, your phone number, email or Google. No password. The same account carries your progress, your certificates and anything else you do with Nexgino later.

Sign in to continue

It takes about fifteen seconds.

Previous Next lesson All lessons