How to Create Model in Laravel 9

Hello Artisan,

In this tutorial, I will show you how to create model in laravel 9. We can create a model in Laravel with a command line or we can create it manually. It is very easy to create a model in Laravel application using the command line. Just run the below command to create a model.

php artisan make:model ModelName

php artisan make:model Product


You can create a model with database migration also. Just run the below command:

php artisan make:model Product -m


If you run this command, You will see a Product model in your model's directory and -m will create a table for your product migration also. You can also create factory, resource controller, and model with migration with one command. Just run the below command:'

php artisan make:model Product -mrf

//m for migration
//r for resource controller
//f for factory


Read also: Creating File Manager in Laravel Step By Step Guide


Hope it can help you.


Facebook Github
A web enthusiastic, a self-motivated full-stack software engineer from Dhaka, Bangladesh with experience in developing applications using Laravel , React and Vue js