apollopy / laravel-x-eloquent
增强型Eloquent for Laravel
2.0.0
2018-11-29 19:47 UTC
Requires
- php: >=5.6.4
- illuminate/support: ^5.4
README
安装
composer require apollopy/laravel-x-eloquent
更新composer后,将服务提供者添加到config/app.php
文件中的providers
数组中
ApolloPY\Eloquent\EloquentServiceProvider::class,
Laravel 5.5使用包自动发现,因此不需要手动添加ServiceProvider。
扩展
sortByIds
$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
Topic::where('user_id', 1)->chunkByTime(3600, function ($topics) { // });