How use carbon in Laravel 5.2 application-wide

jahsen picture jahsen · Mar 15, 2016 · Viewed 23.4k times · Source

How to use Carbon in Laravel 5.2 without use Carbon\Carbon; added in every View and Controller..?

Answer

zsolt.k picture zsolt.k · Mar 15, 2016

Add the following line to the aliases array in the config/app.php:

'Carbon' => 'Carbon\Carbon'

And you need to add use Carbon; every class where you want to use it.