onlinecode

How to Create Model in Laravel 9 using Command?

How to Create Model in Laravel 9 using Command?

In this post we will give you information about How to Create Model in Laravel 9 using Command?. Hear we will give you detail about How to Create Model in Laravel 9 using Command?And how to use it also give you demo for it if it is necessary.

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

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..

Hope this code and post will helped you for implement How to Create Model in Laravel 9 using Command?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Exit mobile version