How to Create Model in Laravel 7 using Command?

  33734 views   1 year ago Laravel

In this tutorial,i will learn you give to engender a model utilizing a command in laravel 7. you can define the make:model command in your terminal.  you can simply use a command to engender model in laravel 7

Example 1
php artisan make:model Admin
  • This command is used to create a model in laravel project.
  • This command is only created to model in project.
  • It will create to file in project.

1.Model

app/Admin.php

Example 2
php artisan make:model Admin --migration

or

php artisan make:model Admin -m
  • This command is use to create model with migration in laravel project.
  • It will create to files in project.

1.Model

app/Admin.php

2.Migration

migrations/2019_11_25_120400_create_admins_table.php

Example 3
php artisan make:model Admin --controller

or

php artisan make:model Admin -c
  • This command is used to create model with controller in your laravel project.
  • It will create to files in project.

1.Model

app/Admin.php

2.Controller

app/Http/Controllers/AdminController.php

Example 4
php artisan make:model Admin --resource

or

php artisan make:model Admin -r
  • This command is used to create model,controller or crud method in your laravel project.
  • It will create to files in project.

1.Model

app/Admin.php

2.Controller

app/Http/Controllers/AdminController.php

3.crud Method

also create this function in controller : index(),create(),store(),show(),update()

Example 5
php artisan make:model Admin --migration --controller --resource

or

php artisan make:model Admin --all

or

php artisan make:model Admin -a
  • This command is used to create model,migration or controller with crud method in laravel project.
  • It will create to files in project.

1.Model

app/Admin.php

2.Migration

migrations/2019_11_25_120400_create_admins_table.php

3.Controller

app/Http/Controllers/AdminController.php

4.crud Method

also create this function in controller : index(),create(),store(),show(),update()

i hope it will help you lot..

Author : Harsukh Makwana
Harsukh Makwana

Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]

Related Articles