I try to find name of previous route in Laravel 5.1. With:
{!! URL::previous() !!}
I get the route url, but I try to get route name like I
Simply you can do this to achieve it. I hope it helps
In Controller:
$url = url()->previous();
$route = app('router')->getRoutes($url)->match(app('request')->create($url))->getName();
if($route == 'RouteName') {
//Do required things
}
In blade file
@php
$url = url()->previous();
$route = app('router')->getRoutes($url)->match(app('request')->create($url))->getName();
@endphp
@if($route == 'RouteName')
//Do one task
@else
// Do another task
@endif