0

How to write artisan command to create model and controller inside specific directories.

If I do this command::

php artisan make:model Post -mcr

it create Post controller inside controllers folder, Post model inside models directory.

But is there any artisan command or any other process to create controller and model inside Admin-> Services inside Controllers and Models folder respectively. I tried this command::

php artisan make:model Admin\Services\Post  -mc

it created Post model inside models->Admin->Services folder but did not create directory for Post controller.

Thank You!!!

2 Answers 2

1

If you want to do this, then you have to use those commands

php artisan make:model Admin\Services\Post -m; php artisan make:controller Admin\Services\PostController

Or you can do it by separately

php artisan make:model Admin\Services\Post -m
php artisan make:controller Admin\Services\PostController 
Sign up to request clarification or add additional context in comments.

Comments

1

There are multiple ways to create resources like controller, model, migrations, views on sub folders. php artisan make:controller Test/TestController will create a controller inside the Test Folder but when you create as php artisan make:model Test/Test -m migration files won't created inside subfolders, even you created it you have to configure it for run the migration. i use a moduler package which resolve all the issues. you just install the package with composer require raza9798/core-modules and create the resource you want with the command of php artisan module:make FolderName ResourceName it will asks option to create model, controller everything

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.