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 get for current page:
{!! Route::current()->getName() !!}
My client wont a different text for Thank you page, depends on from page (Register page or Contact page) user go to Thank you page. I try with:
{!! Route::previous()->getName() !!}
But that didn't work. I try to get something like:
@if(previous-route == 'contact')
some text
@else
other text
@endif
Here what work for me. I find this answer and this question and modify it to work in my case: https://stackoverflow.com/a/36476224/2807381
I've created a helper function like this.
You can't get route name of previous page, so your options are:
Check previous URL instead of a route name.
Use sessions. First, save route name:
Then check if session has
previous-route
:GET
parameters to pass route name.If I were you, I'd use sessions or would check previous URL.