namespace App\Http\Requests;
class ActionRequest extends Request
{
protected $dates = [
'timestamp',
'timestamp_end'
];
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$rules = [
'timestamp' => 'required',
'user_id' => 'required',
'name' => 'required',
'prm_action_type_id' => 'required'
];
return $rules;
}
public function all($keys = null)
{
$result = parent::all($keys);
$types = app('\App\Repositories\System\Action\TypeRepository');
$actionType = $types->find($result['prm_action_type_id']);
if (!isset($actionType->appointment) && array_key_exists('timestamp_end', $result)) {
unset($result['timestamp_end']);
}
return $result;
}
}
So i expected that if i have aRequest Class with rules and i override the all function the Request gets validated when i call ->all(). Instead i get undefined index prm_action_type_id (that is ok, cause i didnt even sent it to the server, but i expected to be catched by the Rules.)
I think i got here something wrong?