Multi-language support for Laravel Eloquent's dates
qwildz/localized-eloquent-date is a Laravel package for multi-language support for laravel eloquent's dates.
It currently has 4 GitHub stars and 14.443 downloads on Packagist.
Install it with composer require qwildz/localized-eloquent-date.
Discover more Laravel packages by qwildz
or browse all Laravel packages to compare alternatives.
Last updated
This library extends Eloquent for multi-language date support. Replace the use of Carbon in Eloquent to Laravel Date with PHP Trait. And this library support Ardent too.
Add the package to your composer.json and run composer update.
{
"require": {
"qwildz/localized-eloquent-date": "dev-master"
}
}
Add the Laravel Date service provider in app/config/app.php:
'Jenssegers\Date\DateServiceProvider',
And if you need, you can add an alias to use Laravel Date package:
'Date' => 'Jenssegers\Date\Date',
If your model use pure Eloquent, just change your model class to extends Qwildz\LocalizedEloquentDate\LocalizedEloquent clas.
use Qwildz\LocalizedEloquentDate\LocalizedEloquent as Model;
class MyModel extends Model {}
Or if you use Ardent, extends Qwildz\LocalizedEloquentDate\LocalizedArdent class.
use Qwildz\LocalizedEloquentDate\LocalizedArdent as Model;
class MyModel extends Model {}
You still can use the library if you don't use both above with using Qwildz\LocalizedEloquentDate\LocalizedDateTrait trait.
use Qwildz\LocalizedEloquentDate\LocalizedDateTrait;
class MyModel extends Model {
use LocalizedDateTrait;
...
}