make controller artisan command with parameters

1003 0 0 0

Last Updated : 2024-04-24 18:22:13

This command creates a new controller file in app/Http/Controllers folder in laravel with all available parameters

This command creates a new controller file in app/Http/Controllers folder.


Example usage:


php artisan make:controller PostController

Parameters:


--resource

The controller will contain a method for each of the available resource operations – index(), create(), store(), show(), edit(), update(), destroy()


--api

Similar to –resource above, but generate only 5 methods: index(), store(), show(), update(), destroy(). Because create/edit forms are not needed for API.


--invokable

Generates controller with one __invoke() method


--model=Photo

If you are using route model binding and would like the resource controller’s methods to type-hint a model instance.


 


 


 


 

Mahmoud Anwar

Mahmoud Anwar

Back End Developer with a passion for developing innovative web applications that expedite the efficiency and effectiveness of organizational success. Well-versed in technology and writing code to create systems that are reliable and user-friendly. Also has the proven ability to motivate, educate, and collaborate effectively to build web applications and effectively track changes. Confident communicator, strategic thinker, and innovative creator to develop software that is customized to meet a company’s organizational needs, highlight their core competencies, and further their success.