apollopy/laravel-x-eloquent

Enhanced Eloquent for Laravel
15,738 1
Install
composer require apollopy/laravel-x-eloquent
Latest Version:2.0.0
PHP:>=5.6.4
License:MIT
Last Updated:Dec 25, 2018
Links: GitHub  ·  Packagist
Maintainer: apollopy

laravel-x-eloquent

Installation

composer require apollopy/laravel-x-eloquent

After updating composer, add the service provider to the providers array in config/app.php

ApolloPY\Eloquent\EloquentServiceProvider::class,

Laravel 5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.

Extension

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) {
    //
});

Related Packages

wildside/userstamps

Laravel Userstamps provides an Eloquent trait which automatically maintains `cre...

2,157,838 753
cariuk/repository-pattern-laravel

A flexible and powerful Laravel package implementing the Repository Pattern with...

2,948 0
mybizna/automigrator

Declare database migrations and factory definitions inside Laravel models.

1,384 3
kolossal-io/laravel-multiplex

A Laravel package to attach versioned meta data to Eloquent models.

129,032 292
alibayat/laravel-categorizable

Implementing Nested-structure Hierarchy Categories system for Eloquent models.

2,746 60