I want all the links on my site to use HTTPS; however I cannot (for non technical reasons) force users to use HTTPS. I therefore want all URLs generated by Laravel to be prefixed with 'https', but I don't want Laravel to throw an exception if a user visits the URL over 'http'.
I have the following route setup:
Route::get('dashboard', [ 'uses'=>'DashboardController@view' ]);
Can anyone tell me how to get URL::route('dashboard') to return a HTTPS version of the URL, without rewriting my route as:
Route::get('dashboard', [ 'https', 'uses'=>'DashboardController@view' ]);
Or how to write my route as per the second example, but not thrown an exception if then accessed over 'http'?
For creating an https link in a laravel blade view with URL::route , simply use: URL::secure()
http://cheats.jesse-obrien.ca/#urls
URL::secure('foo/bar', $parameters);
URL::secureAsset('css/foo.css');
URL::to('foo/bar', $parameters, $secure);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With