Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/apollopy/laravel-x-eloquent
Enhanced Eloquent for Laravel
https://github.com/apollopy/laravel-x-eloquent
Last synced: 23 days ago
JSON representation
Enhanced Eloquent for Laravel
- Host: GitHub
- URL: https://github.com/apollopy/laravel-x-eloquent
- Owner: apollopy
- License: mit
- Created: 2016-02-18T11:21:34.000Z (almost 9 years ago)
- Default Branch: new
- Last Pushed: 2018-12-25T07:23:05.000Z (about 6 years ago)
- Last Synced: 2024-11-18T06:58:23.265Z (about 2 months ago)
- Language: PHP
- Homepage:
- Size: 21.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# laravel-x-eloquent
## Installation
```base
composer require apollopy/laravel-x-eloquent
```After updating composer, add the service provider to the `providers` array in `config/app.php`
```php
ApolloPY\Eloquent\EloquentServiceProvider::class,
```
**Laravel 5.5** uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.## Extension
### sortByIds
```php
$ids = [3, 1, 2];
$posts = Post::find($ids); // collection -> [1, 2, 3]
$posts = $posts->sortByIds($ids); // collection -> [2 => 3, 0 => 1, 1 => 2]
$posts = $posts->values(); // collection -> [3, 1, 2]
```### chunkByTime
```php
Topic::where('user_id', 1)->chunkByTime(3600, function ($topics) {
//
});
```