Reputation: 119
i have a controller with 5 methods store / rename / duplicate / move / delete
comming from deferent Forms with POST.
And i want to use Form Request for Validation like that :
any adea on how to validate all my forms without creating a request form file for each Form.
Upvotes: 0
Views: 952
Reputation: 451
You can use $this->route()->getActionName()
to the get the current action. ie. MyController@store, MyController@rename, MyController@delete, ...
Then in your SectionRequest you can do something like this:
public function rules(){
$arr = explode('@', $this->route()->getActionName());
$method = $arr[1]; // The controller method
switch ($method) {
case 'store':
// do something.
break;
case 'rename':
// do something.
break;
case 'delete':
// .... and so
}
}
Upvotes: 1