Reputation: 2716
Apologies in advance if this is a noob question
I have a delete function in Laravel, I am having problems with the route and returning variables I need when the website is hosted externally.
I currently have the URL coded like this
<a href="http://localhost:8888/Laravel/test/public/safesign_doc_delete/{{$file}}/{{$sector_name}}/{{$selected_sector}}">Delete</a></td>
I would like this url to be dynamic. I have tried the public_path() function but have had no prevail.
<a href="{{public_path()}}/safesign_doc_delete/{{$file}}/{{$sector_name}}/{{$selected_sector}}">Delete</a></td>
Thanks
Upvotes: 0
Views: 2067
Reputation: 1604
url() is the default helper function get your hosting url which is found in the app.php under 'url' => 'http://localhost'
(or other)
This will solve your URL problem
NOTE
if you are worried about changing it when it goes to production don't worry. Laravel gives you folder options where you can have LOCAL as a folder with localhost as your url and then the main app.php file can be your production settings.
Upvotes: 0
Reputation: 3664
You can use url()
for example, like this:
<a href="{{ url() }}/safesign_doc_delete/{{$file}}/{{$sector_name}}/{{$selected_sector}}">Delete</a>
You can also call link helpers:
{{ link_to('safesign_doc_delete/'.$file.'/'.$sector_name.'/'.$selected_sector, 'Delete') }}
Upvotes: 0
Reputation: 1541
You should use the routing system to generate urls ,and not create them by hand, it's quite easy:
http://laravel.com/docs/routing
the concept is simple: 1) create a route in the routes.php file 2) use it with the route() helper
edit: to use a route and let LARAVEL generate the correct url , you simply have to do something similar to this (supposing that you are using blade):
<a href="{{route('name_of_the_route',array('parameter1'=>$value1,'parameter2'=> "value2,... ))}}">Delete</a>
Upvotes: 1