'Retrieve and display the Url where a form has been completed in Laravel 5
I would like to add a feature to my messenger.
When a buyer sends a message to a seller from a listing, only from a listing (www.website.com/listings/...) I would like to add a link to this listing in the messenger so that the seller can find the reference listing.
Here is the code (which does not work):
In message.blade.php (form):
<input name="listingurl" type="hidden" value="<?php echo url()->current();?>">
In MController.php:
$listingurl = Input::get('listingurl');
In show.blade.php (messenger):
<a href="{{ $listingurl }}">Listing</a>
Thank you for your help!
Solution 1:[1]
follow this options from laravel api to see what you want
https://laravel.com/api/5.5/Illuminate/Routing/UrlGenerator.html#method_previous
here an example to Get the URL for the previous request without to use hidden input .
$listingurl = url()->previous();
and you can use it in your code for easy way i don't understand what do you want but this may help you
<a href="{{ $listingurl }}">Listing</a>
i wish this solution saved your day
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mahmoud Ibrahim |
