How to make Model and Migration in Laravel 8

How to make Model and Migration in Laravel 8


In this tutorial, you will learn how to make model and migration in laravel 8.

Before starting to create model and migration in laravel you need to create a new laravel project

Method 1:

Let's create a Model in Laravel by following command: 

$ php artisan make:model Student

In this above artisan command the Model name is Student, which is highlighted with yellow color.


Let's create a Migration (mysql table) in Laravel by following command: (table name will should always be plural in laravel)

$ php artisan make:migration create_students_table

In this above command the table name is students which is highlighted with yellow color.

After creating the Migration successfully in Laravel, add some columns to the table, and then migrate this tables in to your database by the following command:

$ php artisan migrate


Method 2:

Let's create a Model and Migration both in Laravel by following command:

$ php artisan make:model Student -m

In this above we are creating two things one is Model and another one is Migration with the name as Student. so,

First, Model will be created in the path: app/Models/Student.php

Second, Migration will be created in the path: database/migration/2021_02_16_create_students_table.php 


Thanks for reading...