apollopy/laravel-x-eloquent

Enhanced Eloquent for Laravel
15,737 1
Install
composer require apollopy/laravel-x-eloquent
Latest Version:2.0.0
PHP:>=5.5.9
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

kodeine/laravel-acl

Light-weight role-based permissions for Laravel 5 built in Auth system.

361,293 777
hootlex/laravel-friendships

This package gives Eloquent models the ability to manage their friendships.

119,502 700
spatie/laravel-sluggable

Generate slugs when saving Eloquent models

13,300,010 1,552
mpociot/laravel-firebase-sync

Synchronize your Eloquent models with a Firebase realtime database.

153,302 265