Reputation: 382
I have on my web.php this route
Route::get('/manager/posts/create', 'PostController@index')->name('createArticle');
is there a way to call this route from controller on return view instead of his route return view('manager.posts.crear');
something like return view('createArticle')
?
Upvotes: 2
Views: 1602
Reputation: 576
You are looking for named routes:
https://laravel.com/docs/5.8/routing#named-routes
return redirect()->route('createArticle');
Upvotes: 2
Reputation: 8618
Try this
use Illuminate\Support\Facades\Route;
public function index(Request $request)
{
$routeName = Route::currentRouteName();
// or $routeName = $request->route()->getName();
return view($routeName);
}
Upvotes: 2