I'm trying to make a custom redirect function. I have created a custom route function in a new file (helpers.php) that works fine:
if (! function_exists('cms_route')) {
/**
* Generate a URL to a named route with predefined cms path.
*
* @param string $name
* @param array $parameters
* @param bool $absolute
* @param \Illuminate\Routing\Route $route
* @return string
*/
function cms_route($name, $parameters = [], $absolute = true, $route = null)
{
return app('url')->route(config('constants.cms_path').'.'.$name, $parameters, $absolute, $route);
}
}
I'm trying to call this function with redirect()->cms_route('name')
instead of redirect()->route('name')
So when the cms path is changed everything keeps working.
How would I accomplish this?