I've been trying to add a FormRequest
with rules and message to my delete method, but the request is coming back empty and the rules are failing every time.
Is it possible to get the request data in a delete method?
Here's my request class:
use App\Http\Requests\Request;
class DeleteRequest extends Request
{
/**
* 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 [
'staff_id' => ['required', 'exists:users,uid'],
'reason' => ['required', 'string'],
];
}
/**
* Get custom messages for validator errors.
*
* @return array
*/
public function messages()
{
return [
'staff_id.required' => staticText('errors.staff_id.required'),
'staff_id.exists' => staticText('errors.staff_id.exists'),
'reason.required' => staticText('errors.reason.required'),
'reason.string' => staticText('errors.reason.string'),
];
}
}
And the controller:
/**
* Handle the 'code' delete request.
*
* @param integer $id The id of the code to fetch.
* @param DeleteRequest $request The request to handle the data.
* @return response
*/
public function deleteCode($id, DeleteRequest $request)
{
dd($request->all());
}