Laravel 8 create controller and model using php artisan make:model and php artisan make:controller commands on command line.
In this tutorial, we will show you how to create a simple controller using an artisan command with cmd, how to create a resource controller and api resource controller using the command with cmd, and how to model and migration using the command with cmd.
You can use the **php artisan make model for creating a **model using the command line (CLI) :
php artisan make:model Product
This command is to create the Product model, which is a placed on the app/models directory.
You can use the php artisan make:controller command for creating a controller using this command line:
php artisan make:controller ProductController
This command will create controller named ProductController, Which is placed on app/http/controllers directory.
To create the resource controller in laravel 8, so, you can execute the following command on command prompt:
php artisan make:controller ProductController --resource
PHP artisan make controller resource command creates a resource controller. It has already created some methods like index, update, edit, destroy, etc.
If you want to create controller and model, so you can execute php artisan make:model -mc for creating a controller and model in command prompt:
php artisan make:model Product -mc
#laravel