Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.4] Add getActionMethod to Route class #18105

Merged
merged 3 commits into from
Feb 25, 2017
Merged

Conversation

filipeaclima
Copy link
Contributor

@filipeaclima filipeaclima commented Feb 24, 2017

With the 'getActionName' we'd get the full namespace of the Controller plus the method that is called inside it. This function returns only the name of the method that is called inside the Controller.
I'm assuming that this is useful only for those who have Route actions in the form Controller@method, otherwise 'Closure' is always returned from both methods.

This would be nice to have, at least for my use case:

I'll have several App\Http\Requests<ControllerName>Request classes (one for each Controller where Form Request Validation is needed) that extend from a base App\Http\Requests\Request.

On the child classes I'll have methods with the same name of the Controller methods. Example: if the Controller as a 'store' method, I'll have a 'store' method on my Request that returns the rules needed for that validation.

On the base class, I'll have the usual 'rules' method that would do the following:

if (method_exists($this, $this->route()->getActionMethod())) {
  return $this->{$action}();
}
return [];

I'm not sure if this is really usefull or not, but I thought I should share it anyway.

@taylorotwell taylorotwell merged commit 8be9acf into laravel:5.4 Feb 25, 2017
@GrahamCampbell GrahamCampbell changed the title Add getActionMethod to Route.php [5.4] Add getActionMethod to Rout class Feb 25, 2017
@GrahamCampbell GrahamCampbell changed the title [5.4] Add getActionMethod to Rout class [5.4] Add getActionMethod to Route class Feb 25, 2017
@filipeaclima filipeaclima deleted the patch-1 branch February 27, 2017 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants