1. Creating a Model:
php artisan make:model Post
This command creates a new model file named Post.php
in the app/Models
directory.
2. Creating a Model with a Migration:
php artisan make:model Post -m
This is the most common and recommended approach, as it creates both the model and the corresponding database migration in one step
3. Creating a Model with a Factory:
php artisan make:model Post -f
This will create the model along with a factory file in database/factories
.
4. Creating a Model with a Seeder:
php artisan make:model Post -s
This will create the model along with a seeder file in database/seeders
.
5. Creating a Model with a Controller:
php artisan make:model Post -c
This will create the model and its controller file in app/Http/Controllers
.
6. Combining Options:
php artisan make:model Post -mfcs
This will create Model, Factory, Migration, Seeder, Controller
7. Specifying the Table Name:
php artisan make:model Post --table=blog_posts -m
This will create a migration that creates the blog_posts
table instead of posts
.