R0KKET
R0KKET

Reputation: 85

How to create a controller in a sub-folder when defining as a parameter?

I'm creating a project with Laravel and I'm aware that there is a way to create the migration and controller (with or without resources) along with the model with php artisan make:model ExampleModel -m -c -r.

In my project I have models and controllers in sub-folders. I'm able to add the model and controllers to sub-folders when creating them separately (php artisan make:model Models/example_model and same in controllers). But I don't know how to add the controllers to a sub-folder when creating them with a parameter on the make:model command.

I really appreciate any help you can provide.

I've tried the below commands already and they don't appear to be working

php artisan make:model Models/example -m -MyControllers/c -r

php artisan make:model Models/example -m MyControllers/-c -r

Upvotes: 0

Views: 1267

Answers (2)

Vipertecpro
Vipertecpro

Reputation: 3274

This will create sub-folder for both models and controller and files into it

php artisan make:controller TestFolder\TestController --model=Models\TestModel

I hope this helps.

Happy Coding :)

Upvotes: 2

SimonDepelchin
SimonDepelchin

Reputation: 2080

I'm not sure it's possible with the make:model command. My best guess is to use 2 commands:

php artisan make:model Models/NewModel -m

php artisan make:controller MyControllers/NewModelController -r

Upvotes: 0

Related Questions