t0berius's avatar

generate URL (https) from route with title

What's the easiest way to generate a URL to a controller action (exampleController@index) with HTTPs active and set a title, so a HTML link like this would be generated in view:

 <a href="https://www.example.com/sample">sample title</a> 

I tried to use link_to_action() but seems like this helper function isn't avaible in view?

0 likes
5 replies
bobbybouwmann's avatar

There is an action method from laravel

{{ action('ExampleController@index', $parameters) }}

This will only output https if the site runs on https. If you run this site locally it will probably not return https, but in production it will ;)

1 like
t0berius's avatar

@bobbybouwmann

This works fine. I now use:

{!! link_to_action('DashboardController@settings', 'Settings') !!}

I need to "unescape" the URL, otherwise blade will show the URL as text. Will the URL change to HTTPs in case of production automatic too (production system is HTTPs)?

bobbybouwmann's avatar

Yeah, Laravel will detect this most of the time, so you don't need to worry about it at all ;)

And if your server is setup correctly it knows it needs to redirect to https anyway :D

Please or to participate in this conversation.