Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #100 from LaravelRUS/master
Browse files Browse the repository at this point in the history
Laravel 5.5
  • Loading branch information
Amegatron authored Apr 22, 2018
2 parents 03dc289 + d609196 commit cecdc97
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 36 deletions.
75 changes: 40 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# Maintainers needed
Sorry, I have not much time supporting this repo. Also I rarely work with Laravel now, so new maintainers are needed.

# Maintainers needed
Sorry, I have not much time supporting this repo. Also I rarely work with Laravel now, so new maintainers are needed.

# Localized Carbon

for **L4** use **1.4** branch
for **L5** use **dev-master**
for **L5.4** use **2.2**
for **>=L5.5** use **2.3**

See also [localized documentation](docs)

+ [Introduction](#intro)
+ [Installation](#installation)
+ [Usage](#usage)
+ [Supported languages](#languages)
+ [Installation](#installation)
+ [Extending](#extending)
+ [Contributing](#contributing)

Expand All @@ -20,6 +21,40 @@ See also [localized documentation](docs)

Localized Carbon is an extension of a popular Carbon package, designed specially for Laravel framework. By localization I mean its `diffForHumans` function, which returns a human-readable string of time interval. This package also supports genitive months by introducing the "%f" key in `formatLocalized` method.


<a name="installation"></a>
## Installation

Add the following requirement to your `composer.json`: `"laravelrus/localized-carbon": "1.*"` and then run `composer update`.

Next, add package's Service Provider to `app/config/app.php` in `providers` section:

```
'Laravelrus\LocalizedCarbon\LocalizedCarbonServiceProvider',
```

After that you may want to add some Aliases (`aliases` section of the same config):

```
'LocalizedCarbon' => Laravelrus\LocalizedCarbon\LocalizedCarbon::class,
'DiffFormatter' => Laravelrus\LocalizedCarbon\DiffFactoryFacade::class,
```

Note that `DiffFormatter` will only be used for extending default localizations. See [extending Localized Carbon](#extending).

If you want to use the power of `LocalizedCarbon` the same way as you did with original `Carbon` in your models, you may want to use supplied trait for this in your models:

```
use \Laravelrus\LocalizedCarbon\Traits\LocalizedEloquentTrait;
```

In this case `LocalizedCarbon` will be used for all dates in your Eloquent model instead of original `Carbon`.

Note that this method is actual for PHP versions 5.4 and higher.

If you are still using PHP 5.3.7 you can substitute Laravel's Eloquent class by `Laravelrus\LocalizedCarbon\Models\Eloquent` supplied with this package. To do this you can either inherit this class directly, or make an alias to it instead of originial Eloquent in `app\config\app.php`.


<a name="usage"></a>
## Usage

Expand Down Expand Up @@ -66,37 +101,7 @@ Current version of Localized Carbon ships with these localizations:

But it is extendable, so you may write and use your own localization without altering the contents of the package. See [extending Localized Carbon](#extending).

<a name="installation"></a>
## Installation

Add the following requirement to your `composer.json`: `"laravelrus/localized-carbon": "1.*"` and then run `composer update`.

Next, add package's Service Provider to `app/config/app.php` in `providers` section:

```
'Laravelrus\LocalizedCarbon\LocalizedCarbonServiceProvider',
```

After that you may want to add some Aliases (`aliases` section of the same config):

```
'LocalizedCarbon' => Laravelrus\LocalizedCarbon\LocalizedCarbon::class,
'DiffFormatter' => Laravelrus\LocalizedCarbon\DiffFactoryFacade::class,
```

Note that `DiffFormatter` will only be used for extending default localizations. See [extending Localized Carbon](#extending).

If you want to use the power of `LocalizedCarbon` the same way as you did with original `Carbon` in your models, you may want to use supplied trait for this in your models:

```
use \Laravelrus\LocalizedCarbon\Traits\LocalizedEloquentTrait;
```

In this case `LocalizedCarbon` will be used for all dates in your Eloquent model instead of original `Carbon`.

Note that this method is actual for PHP versions 5.4 and higher.

If you are still using PHP 5.3.7 you can substitute Laravel's Eloquent class by `Laravelrus\LocalizedCarbon\Models\Eloquent` supplied with this package. To do this you can either inherit this class directly, or make an alias to it instead of originial Eloquent in `app\config\app.php`.

<a name="extending"></a>
## Extending Localized Carbon
Expand Down
13 changes: 12 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,24 @@
],
"require": {
"php": ">=5.3.0",
"illuminate/support": ">=5.4.0",
"illuminate/support": ">=5.5.0",
"nesbot/carbon": "^1.24"
},
"autoload": {
"psr-0": {
"Laravelrus\\LocalizedCarbon\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"Laravelrus\\LocalizedCarbon\\LocalizedCarbonServiceProvider"
],
"aliases": {
"LocalizedCarbon": "Laravelrus\\LocalizedCarbon\\LocalizedCarbon",
"DiffFormatter": "Laravelrus\\LocalizedCarbon\\DiffFactoryFacade"
}
}
},
"minimum-stability": "stable"
}

0 comments on commit cecdc97

Please sign in to comment.