April 14, 2018 —John Koster
The asset
function will return a URI composed of the application's URI and the given $path
. If $secure
is true
, the returned URI will have the https://
schema, otherwise it will have the http://
schema.
The application URI used to generate the final URI is what was used to issue the request, and typically matches what appears in the browser's address bar.
The signature of the asset
function is:
1function asset(2 $path,3 $secure = null4);
Assuming the application path is laravel.artisan
the following asset paths can be generated (the resulting URI appears above the function call as a comment):
1// http://laravel.artisan/test2asset('test');3 4// http://laravel.artisan/js/application.min.js5asset('js/application.min.js');6 7// http://laravel.artisan/js/application.min.js8asset('http://laravel.artisan/js/application.mins.js');
∎
The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.