easteregg / intl-carbon by easteregg

Laravel 5 Package Template
425
0
2
Package Data
Maintainer Username: easteregg
Maintainer Contact: isthereanybody@gmail.com (Mohammadreza Ghorbani)
Package Create Date: 2017-02-04
Package Last Update: 2021-07-22
Language: PHP
License: proprietary
Last Refreshed: 2024-05-12 03:09:06
Package Statistics
Total Downloads: 425
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

Build Status

Laravel 5.4 Eloquent Carbon Methods

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.

Installation

  1. run composer require easteregg/intl-carbon
  2. add Easteregg\IntlCarbon\IntlServiceProvider to config/app.php providers.
  3. 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

see: (https://secure.php.net/manual/en/class.intldateformatter.php)

For more information about the formatting, checkout this page. Edit your eloquent model and add Easteregg\IntlCarbon\LocalizesDates trait.

example:

<?php

use Easteregg\IntlCarbon\LocalizesDates;

class Post extends Model
{
   use LocalizesDates;
}


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.