Ceci est une ancienne révision du document !
php artisan make:request StoreBlogPost
On peut coder directement une autorisation et rediriger ou on veut.
/** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { return \Auth::user()->has_role('ADMIN'); } /** * Get the response for a forbidden operation. */ public function forbiddenResponse() { return redirect('/')->with('flash_error',"Seul ADMIN peut..."); }
Pour personnaliser le format du retour d’erreur
protected function formatErrors(Validator $validator) { return $validator->errors()->all(); }