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

Commit

Permalink
Changed Eloquent functionality to trait
Browse files Browse the repository at this point in the history
  • Loading branch information
Amegatron committed Nov 17, 2014
1 parent 6c378a3 commit 97ce04a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,14 @@ After that you may want to add some Aliases (`aliases` section of the same confi

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 substitute Laravel's Eloquent model by changing the alias for `Eloquent` (assuming that your models extend this class):
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:

```
'Eloquent' => 'Laravelrus\LocalizedCarbon\Models\Eloquent',
use \Laravelrus\LocalizedCarbon\Traits\LocalizedEloquentTrait;
```

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

<a name="extending"></a>
## Extending Localized Carbon

Expand Down
6 changes: 4 additions & 2 deletions docs/README-ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,14 @@

Стоит отметить, что класс `DiffFormatter` будет использоваться только для расширения пакета дополнительными локализациями. См. [расширение пакета](#extending).

Если вы хотите использовать `LocalizedCarbon` привычным способом, то можете подменить класс Eloquent-модели путем изменения соответствующего алиаса `Eloquent` в конфиге:
Если вы хотите использовать `LocalizedCarbon` привычным способом в ваших моделях, то можете воспользоваться поставляемым трейтом:

```
'Eloquent' => 'Laravelrus\LocalizedCarbon\Models\Eloquent',
use \Laravelrus\LocalizedCarbon\Traits\LocalizedEloquentTrait;
```

В этом случае для всех дат в вашей ELoquent-модели будет использоваться `LocalizedCarbon` вместо исходного `Carbon`.

<a name="extending"></a>
## Расширение пакета

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?php namespace Laravelrus\LocalizedCarbon\Models;
<?php namespace Laravelrus\LocalizedCarbon\Traits;


use Illuminate\Database\Eloquent\Model;
use Laravelrus\LocalizedCarbon\LocalizedCarbon;

class Eloquent extends Model {
trait LocalizedEloquentTrait {
/**
* Return a timestamp as DateTime object.
*
Expand Down

0 comments on commit 97ce04a

Please sign in to comment.