Skip to content

Instantly share code, notes, and snippets.

@matthijs110
Created May 11, 2016 18:16
Show Gist options
  • Save matthijs110/4e33c07ed49d5831d04d94b5eaf7d160 to your computer and use it in GitHub Desktop.
Save matthijs110/4e33c07ed49d5831d04d94b5eaf7d160 to your computer and use it in GitHub Desktop.
<?php
namespace App\Providers;
use Blade;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Perform post-registration booting of services.
*
* @return void
*/
public function boot()
{
// Use @humantime($expression) to output a Carbon time object as human readable time.
Blade::directive('humantime', function($expression) {
return "<?php echo with{$expression}->diffForHumans(); ?>";
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment