All Projects → werxe → Laravel Collection Macros

werxe / Laravel Collection Macros

Licence: mit
Custom Laravel Collection Macros.

Programming Languages

macros
77 projects

Projects that are alternatives of or similar to Laravel Collection Macros

Laravel Collection Macros
A set of useful Laravel collection macros
Stars: ✭ 1,069 (+6188.24%)
Mutual labels:  laravel, collection
Mynotes
笔记、Laravel、PHP、面试题、MySQL、HTML、CSS、Java...
Stars: ✭ 201 (+1082.35%)
Mutual labels:  laravel, collection
Collect.js
💎  Convenient and dependency free wrapper for working with arrays and objects
Stars: ✭ 5,440 (+31900%)
Mutual labels:  laravel, collection
Laravel Love
Add Social Reactions to Laravel Eloquent Models. It lets people express how they feel about the content. Fully customizable Weighted Reaction System & Reaction Type System with Like, Dislike and any other custom emotion types. Do you react?
Stars: ✭ 822 (+4735.29%)
Mutual labels:  laravel
Transit
Easy file uploading and downloading for Laravel 5.
Stars: ✭ 5 (-70.59%)
Mutual labels:  laravel
Aetherupload Laravel
A Laravel package to upload large files 上传大文件的Laravel扩展包
Stars: ✭ 835 (+4811.76%)
Mutual labels:  laravel
Laravel Bootstrap Table List
Bootstrap table list generator for Laravel.
Stars: ✭ 16 (-5.88%)
Mutual labels:  laravel
Laravel Blade Directives
A collection of nice Laravel Blade directives
Stars: ✭ 813 (+4682.35%)
Mutual labels:  laravel
Laravel Collectable
Stars: ✭ 7 (-58.82%)
Mutual labels:  laravel
Laravel Sluggable
An opinionated package to create slugs for Eloquent models
Stars: ✭ 831 (+4788.24%)
Mutual labels:  laravel
Package Skeleton
📦 My base for PHP packages.
Stars: ✭ 6 (-64.71%)
Mutual labels:  laravel
Laravel Jade
[Discontinued] Laravel package that adds Jade templating support
Stars: ✭ 5 (-70.59%)
Mutual labels:  laravel
Scaffold Interface
🚀 A Smart CRUD Generator For Laravel
Stars: ✭ 836 (+4817.65%)
Mutual labels:  laravel
Laravel Event Broadcast
Laravel event broadcasting with Node.js, Redis & Socket.io
Stars: ✭ 5 (-70.59%)
Mutual labels:  laravel
Laravel Stager
Laravel Stager State Machine, Its purpose is to add state machine functionality to models
Stars: ✭ 16 (-5.88%)
Mutual labels:  laravel
Awesome Magento2
Curated list of awesome Magento 2 Extensions, Resources and other Highlights
Stars: ✭ 817 (+4705.88%)
Mutual labels:  collection
Lvlgrid
✨ Grid helper to your Laravel application. Filter, order and pagination ajax
Stars: ✭ 7 (-58.82%)
Mutual labels:  laravel
Menu
Menu and sidebar management package for Laravel
Stars: ✭ 6 (-64.71%)
Mutual labels:  laravel
Barcode
Laravel 5 Barcode Generator
Stars: ✭ 826 (+4758.82%)
Mutual labels:  laravel
Laravel Like Vue Validator
An input validator mixin for Vue.js
Stars: ✭ 7 (-58.82%)
Mutual labels:  laravel

Laravel Collection Macros

Build Status Software License Latest Version on Packagist Total Downloads

Custom Laravel Collection Macros for Laravel 8.

This package is compliant with the FIG standards PSR-1, PSR-2 and PSR-4 to ensure a high level of interoperability between shared PHP. If you notice any compliance oversights, please send a patch via pull request.

Version Matrix

Version Laravel PHP Version
5.x 8.x >= 7.3
4.x 7.x >= 7.2.5
3.x 6.x >= 7.2
2.x 5.8.x >= 7.1.3
1.x 5.7.x >= 7.1.3

Getting Started

Install the package via Composer by running:

composer require werxe/laravel-collection-macros

By default all macros are enabled and the macro name is the lower cased version of the macro class.

If you want to customize which macros are enabled or just rename the macro name, you can do so by publishing the configuration file, by running:

php artisan vendor:publish --tag="werxe:collection-macros.config"

The configuration file is now published at config/werxe/collection-macros/config.php.

Documentation

Available Macros

increment

Increment a value that's inside a Collection

$collection = collect([
    'total' => 1,
]);

$collection->increment('total', 2); // 3

decrement

Decrement a value that's inside a Collection

$collection = collect([
    'total' => 3,
]);

$collection->decrement('total', 2); // 1

ksort

Sorts the Collection by its keys.

$collection = collect(['d' => 'lemon', 'a' => 'orange', 'b' => 'banana', 'c' => 'apple']);

$collection->ksort(); // ['a' => 'orange', 'b' => 'banana', 'c' => 'apple', 'd' => 'lemon']

krsort

Sorts the Collection by its keys in the reverse order

$collection = collect(['d' => 'lemon', 'a' => 'orange', 'b' => 'banana', 'c' => 'apple']);

$collection->krsort(); // ['d' => 'lemon', 'c' => 'apple', 'b' => 'banana', 'a' => 'orange']

recursive

Recursively convert nested arrays into Laravel Collections.

$collection = collect([
    'name' => 'John Doe',
    'emails' => [
        '[email protected]',
        '[email protected]',
    ],
    'contacts' => [
        [
            'name' => 'Richard Tea',
            'emails' => [
                '[email protected]',
            ],
        ],
    ],
]);

// Convert the nested arrays into Collections
$convertedCollection = $collection->recursive();

// Get the contacts as a Collection
$contacts = $convertedCollection->get('contacts');

Contributing

Thank you for your interest in Laravel Collection Macros. Here are some of the many ways to contribute.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

License

Laravel Collection Macros is licenced under the MIT License (MIT). Please see the license file for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].