I am using a FormRequest to validate a delete request, but I do not need to access the request inside of my controller. I just need it for validation.
I find the unused variable annoying, but I can't see anything in the docs that suggests I can call anything on the class to validate it.
Form request:
class DeleteList extends FormRequest
{
protected $errorBag = 'delete_list';
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'confirm' => 'required|accepted'
];
}
}
Controller:
public function postDelete(DeleteList $request, ListService $listService, $site, $list)
{
$listService->delete($site, $list);
return redirect()->route('site.lists', ['site' => $site]);
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire