Controller
By default, the full CRUD (Create, Read, Update, Delete) of a model is described by a Laravel resource controller. To get started, after installing it locally, run the command to generate a new controller:
Controller Generation
This command will create a new controller in the app/Admin/Controllers
directory named UserController.php
. Consider a standard, generated resource:
The controller will belong to the model specified in the $model
property. Or return the model from the getModel method. By default, you need to describe the logic for displaying 3 endpoints, they are described by the following methods: index
, matrix
, and show
. The remaining endpoints are served by the extension automatically.
You can generate a simple controller that does not belong to the model and describe absolutely custom logic in it.
Default tools
The parent controller has an explanation
method for declaring global declarations, by default declarations are declared for the first card that will be included on the page, the defaultTools
setting is enabled for it. If the controller has a defaultTools
method, it will be used to check if the tools are displayed. For example, you can disable deletion for a model with id
= 1 in the cards: