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

筅森魡賤 提交于 2019-12-13 03:49:51

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!