Skip to content

Instantly share code, notes, and snippets.

@Krato
Last active May 6, 2019 10:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Krato/1c8d71b8688f646a3c9df3501ce341f3 to your computer and use it in GitHub Desktop.
Save Krato/1c8d71b8688f646a3c9df3501ce341f3 to your computer and use it in GitHub Desktop.
Laravel versioned assets helper #laravel
<?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