This package is for enabling the usage of Chronos in Laravel, this will not cover all cases but at least gives you Chronos instances in favor of Carbon, most of the time. (You'll see that in the Laravel source there are enough cases where it calls Carbon directly.)
The preferred method of installation is via Composer. Run the following
command to install the package and add it as a requirement to your project's
composer.json
:
composer require cino/laravel-chronos
There are now 2 options to add this behaviour to your models. Either of the options will override functions to return a Chronos object instead of a Carbon object, the first and preferred option is to use the Chronos trait from \Cino\LaravelChronos\Eloquent\Chronos like below:
use Cino\LaravelChronos\Eloquent\Chronos;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
use Chronos;
}
The second option is to change your models to extend the Model class from \Cino\LaravelChronos\Eloquent\Model which actually also uses the trait from above.
use Cino\LaravelChronos\Eloquent\Model;
class MyModel extends Model
{
}
This open-source software is licenced under the MIT license.