November 21, 2016 —John Koster
asset($path, $secure = null)
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.
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<?php 2 3// http://laravel.artisan/test 4asset('test'); 5 6// http://laravel.artisan/js/application.min.js 7asset('js/application.min.js'); 8 9// http://laravel.artisan/js/application.min.js10asset('http://laravel.artisan/js/application.mins.js');11~~~
∎
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.