Last active
May 6, 2019 10:40
-
-
Save Krato/1c8d71b8688f646a3c9df3501ce341f3 to your computer and use it in GitHub Desktop.
Laravel versioned assets helper #laravel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Generate a URL to an application asset with a versioned timestamp parameter. | |
* | |
* @param string $path | |
* @param boolean $secure | |
* @return string | |
*/ | |
function versioned_asset($path, $secure = null) | |
{ | |
$timestamp = @filemtime(public_path($path)) ?: 0; | |
return asset($path, $secure) . '?' . $timestamp; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment