From 6747ca52349ec5b9de08f5ac28141e4b94d92a9c Mon Sep 17 00:00:00 2001 From: Bogdan Revutchi Date: Wed, 18 Apr 2018 20:17:26 +0300 Subject: [PATCH 1/4] Laravel auto-discovery --- composer.json | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/composer.json b/composer.json index 55fe5e9..050ffb4 100644 --- a/composer.json +++ b/composer.json @@ -19,5 +19,16 @@ "Laravelrus\\LocalizedCarbon\\": "src/" } }, + "extra": { + "laravel": { + "providers": [ + "Laravelrus\\LocalizedCarbon\\LocalizedCarbonServiceProvider" + ], + "aliases": { + "LocalizedCarbon": "Laravelrus\\LocalizedCarbon\\LocalizedCarbon", + "DiffFormatter": "Laravelrus\\LocalizedCarbon\\DiffFactoryFacade" + } + } + }, "minimum-stability": "stable" } From 916e744dc8d0fe2ceb0bf81335d703f79ddae2c7 Mon Sep 17 00:00:00 2001 From: Bogdan Revutchi Date: Wed, 18 Apr 2018 21:11:29 +0300 Subject: [PATCH 2/4] readme.md update --- README.md | 72 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 0e702b3..95a78e3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# 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 @@ -9,9 +9,9 @@ for **L5** use **dev-master** See also [localized documentation](docs) + [Introduction](#intro) ++ [Installation](#installation) + [Usage](#usage) + [Supported languages](#languages) -+ [Installation](#installation) + [Extending](#extending) + [Contributing](#contributing) @@ -20,6 +20,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. + + +## 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`. + + ## Usage @@ -66,37 +100,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). - -## 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`. ## Extending Localized Carbon From e7c42305120831e83b358e757ac000412cc4c399 Mon Sep 17 00:00:00 2001 From: amega Date: Sun, 22 Apr 2018 16:10:25 +0300 Subject: [PATCH 3/4] Raised minimal Laravel version to 5.5 due to auto-discovery --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 050ffb4..956c82b 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ ], "require": { "php": ">=5.3.0", - "illuminate/support": ">=5.4.0", + "illuminate/support": ">=5.5.0", "nesbot/carbon": "^1.24" }, "autoload": { From d60919674463d4027925b54eaa28bfec8da395c6 Mon Sep 17 00:00:00 2001 From: amega Date: Sun, 22 Apr 2018 16:12:34 +0300 Subject: [PATCH 4/4] README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 95a78e3..7b68712 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,8 @@ Sorry, I have not much time supporting this repo. Also I rarely work with Larave # 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)