secure_asset($path)
The secure_asset
function will return a URI composed of the application's URI and the given $path
. It internally makes a call to the asset
(discussed in the Laravel URL Helper Function: asset article) helper function and always passes true
as the argument for the $secure
parameter.
The following:
1<?php
2
3// https://laravel.artisan/js/application.min.js
4secure_asset('js/application.min.js');
is equivalent to calling:
1<?php
2
3// https://laravel.artisan/js/application.min.js
4asset('js/application.min.js', true);
#Notes on asset
and secure_asset
If the supplied $path
to asset
and secure_asset
contains a protocol, that protocol is used regardless of what function or flags are set. For example, if a URI with the http://
protocol is supplied to the secure_asset
function, the resulting URI will contain the http://
protocol. In addition, if a domain name is supplied to either of the functions, that domain name will be used instead of the domain present in the request.
1<?php
2
3// https://laravel.artisan/js/application.min.js
4asset('https://laravel.artisan/js/application.min.js', false);
5
6// http://laravel.artisan/js/application.min.js
7secure_asset('http://laravel.artisan/js/application.min.js');
8
9// http://laravel.developer/js/application.min.js
10asset('http://laravel.developer/js/application.min.js');
∎