Reputation: 58
i want to add new method to each controller that created by artisan command for example if i run "php artisan make:controller BookController" then i want that BookController file has a method named 'details' by default any way?
Upvotes: 1
Views: 845
Reputation: 349
All controllers extends App\Http\Controllers\Controller
class.
add your method to controller(App\Http\Controllers\Controller.php
) and use that in all your controllers.
Upvotes: 2
Reputation:
Laravel uses "stubs" when creating new models/controllers/migrations etc using php artisan make:...
.
Run php artisan stub:publish
to publish the default stubs into a /stubs/
folder in your project. You can then easily customize those stubs to your liking.
Upvotes: 3
Reputation: 1
I believe you will need to write your own custom make
command to achieve it. There is a link I found that might help you - https://medium.com/@imfx/create-make-custom-commands-in-laravel-9fa002da582e.
Basically, you will need to overwrite make:controller
and use your own stub.
Upvotes: 0