Using backpack/crud: 5.6.0 and laravel 9 here and I want to prevent a user from creating more then n items via the admin's ui "Add Environment" button with link https://example.com/admin/environment/create
When the user presses the button I want to show a simple message that the limit has been reached etc.
Where and how to implement this?
Thanks in advance for any suggestions.
Below are the routes for the Environment model:
GET|HEAD admin/environment .................................................................................................... environment.index › Admin\EnvironmentCrudController@index
POST admin/environment .................................................................................................... environment.store › Admin\EnvironmentCrudController@store
GET|HEAD admin/environment/create ........................................................................................... environment.create › Admin\EnvironmentCrudController@create
POST admin/environment/search ........................................................................................... environment.search › Admin\EnvironmentCrudController@search
PUT admin/environment/{id} ............................................................................................. environment.update › Admin\EnvironmentCrudController@update
DELETE admin/environment/{id} ........................................................................................... environment.destroy › Admin\EnvironmentCrudController@destroy
GET|HEAD admin/environment/{id}/details ..................................................................... environment.showDetailsRow › Admin\EnvironmentCrudController@showDetailsRow
GET|HEAD admin/environment/{id}/edit ............................................................................................ environment.edit › Admin\EnvironmentCrudController@edit
GET|HEAD admin/environment/{id}/show ............................................................................................ environment.show › Admin\EnvironmentCrudController@show
Just stumbled upon https://laravel.com/docs/9.x/eloquent#events-using-closures and by using below function in the Environment model class it works.