ldc-supportweb/app/Http/Requests/UpdateCrudModel.php
Jérémy Munsch b60913525b - bump to Bootstrap 5
- added ACL policies
- added CRUD generic
- added User crud
- added search bar
2021-06-18 15:39:19 +02:00

35 lines
770 B
PHP

<?php
namespace App\Http\Requests;
use App\Enums\CrudAction;
class UpdateCrudModel extends CrudRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
$model = $this->getCurrentModel();
/** @var \App\Models\User|null $user */
$user = auth()->user();
$authorized = auth()->check() and $user->can('update', $model);
if ($authorized) {
$this->rules = $this->getRulesForAction(CrudAction::update());
}
return $authorized;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return $this->rules;
}
}