问题
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
回答1:
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
回答2:
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 :)
来源:https://stackoverflow.com/questions/55324115/how-to-create-a-controller-in-a-sub-folder-when-defining-as-a-parameter