Calling method within URL in Laravel

Asked

Viewed 326 times

1

I have a page with a "back" link. Is there any way to call the method back() of Laravel within the href of the link? That code doesn’t work, but I want something like

href="{{URL::to(back())}}"

1 answer

1


try the following:

href="{{URL::previous()}}"

You can also do with javascript:

<a href="#" onclick="window.history.go(-1);">...</a>
  • It didn’t work. It went back to the previous page I wanted, IE, returned two pages.

  • Strange, I just tested and it worked here. And why doesn’t use javascript @Amandalima? <a href="#" onclick="window.history.go(-1);return false;">...</a>

  • Maybe it didn’t work because the page I want to go back to is coming from a form. When I used {{URL::previous()}} back to the form page.

  • Javascript worked, thank you!

  • You’re welcome @Amandalima. I’ll edit the answer to include this alternative as well

Browser other questions tagged

You are not signed in. Login or sign up in order to post.