kfirba
kfirba

Reputation: 5441

Laravel Redirect::action() fallback?

As the documentation says the function Redirect::action() receives a string which is separated into 2 parts by the symbol @

  1. The controller name
  2. The method name

e.g. Redirect::action('MyController@myFunction')

I've recently tried to give the function an input: Redirect::action('someRouteName') and see what's gonna happen. Surprisingly it didn't return with an error but actually made the link just as if I was using the Redirect::route() function (I had a route named as someRouteName).

Does the function Redirect::action() falls back to Redirect::route() if the value it gets is invalid? Couldn't find any source that says that.

Upvotes: 0

Views: 253

Answers (1)

peter.babic
peter.babic

Reputation: 3374

Yes, it does. Some insight on it can be seen in sources.

https://github.com/laravel/framework/blob/master/src/Illuminate/Routing/UrlGenerator.php#L455

/**
 * Get the URL to a controller action.
 *
 * @param  string  $action
 * @param  mixed   $parameters
 * @param  bool    $absolute
 * @return string
 */
public function action($action, $parameters = array(), $absolute = true)
{
    return $this->route($action, $parameters, $absolute, $this->routes->getByAction($action));
}

Upvotes: 1

Related Questions