In this lab, you will create a Laravel application that includes the following:
- A Model with an associated Migration
- A Factory to generate dummy data
- A View to display data
- A Controller and Route to fetch and render data from the database
- Generate a
Post
model with a migration.php artisan make:model Post -m
- Define the table structure in the migration file.
- Run the migration to create the
posts
table.
- Generate a factory for the
Post
model. - Define the structure for dummy data.
- Call Seeder to generate sample data.
- Create a Blade template for displaying posts.
- Use Blade syntax to loop through and display the posts.
- Generate a
PostController
. - Define an
index
method to fetch and pass posts to the view. - Create a route that maps to the
index
method.