PURPOSE
- Controllers are used when it’s too complex to just specify a (static) view in the
routes
list. - Controllers typically return a view (in the most common case of a web view, thus a rendered HTML page).
USAGE
>php artisan make:controller FooController Description: Create a new controller class Usage: make:controller [options] [--] <name> Arguments: name The name of the class Options: --api Exclude the create and edit methods from the controller. --force Create the class even if the controller already exists -i, --invokable Generate a single method, invokable controller class. -m, --model[=MODEL] Generate a resource controller for the given model. -p, --parent[=PARENT] Generate a nested resource controller class. -r, --resource Generate a resource controller class. -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question --env[=ENV] The environment the command should run under -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
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.
OUTPUT
Output will be in app/Http/Controllers:app/Http/Controllers/FooController.php
Reference: https://laravel.com/docs/6.x/controllers