, (*1)
This package provides a convenient way to localize and format Eloquent date attributes. using this package, you can localize date attributes of any model
to any calendar you want. it looks for the current application locale to generate string., (*2)
Installation
- run
composer require easteregg/intl-carbon
- add
Easteregg\IntlCarbon\IntlServiceProvider
to config/app.php
providers.
- run
php artisan vendor:publish --tag="intl-carbon.config"
to publish the config files. (optional)
Usage
Edit the config file and select a calendar for each locale your application might be having, (*3)
see: (https://secure.php.net/manual/en/class.intldateformatter.php), (*4)
For more information about the formatting, checkout this page.
Edit your eloquent model and add Easteregg\IntlCarbon\LocalizesDates
trait., (*5)
example:, (*6)
```$xslt
<?php, (*7)
use Easteregg\IntlCarbon\LocalizesDates;, (*8)
class Post extends Model
{
use LocalizesDates;
}, (*9)
```, (*10)
You should be good to go. now anywhere in the system, you can call any model date value with a new long() method to format.
(e.g. `$post->created_at->long()).
Pull requests are welcome for this repository., (*11)
#