In laravel is it possible to get the name of the view that called the controller method that you\'re currently in?
I have two version of a form in my site. One is meant
This is how you can achieve that. Just do this in the controller method where you want to detect the previous route name from which came the request.
$url = url()->previous();
$route = app('router')->getRoutes($url)->match(app('request')->create($url))->getName();
if($route == 'route name here') {
return redirect()->back(); //example
}
return view('users.index'); //example