2017 © Pedro Peláez
 

library laradeck-collection-macros

A set of useful Laravel collection macros

image

ngtfkx/laradeck-collection-macros

A set of useful Laravel collection macros

  • Monday, August 28, 2017
  • by ngtfkx
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

laradeck-collection-macros

Latest Version on Packagist ![Software License][ico-license] ![Coverage Status][ico-scrutinizer] Quality Score ![Total Downloads][ico-downloads], (*1)

Набор макросов для расширения стандартного функционала Illuminate\Support\Collection, (*2)

Install

Via Composer, (*3)

``` bash $ composer require ngtfkx/laradeck-collection-macros, (*4)


## Documentation **forSelect(string $valueName, string $keyName = 'id'): array** Метод возвращает ассоциативный массив, где в качестве ключа используется свойство `$keyName` элемента коллекции, а в качестве значения свойство `$valueName`. ``` php $arr = [ ['id' => '10', 'name' => 'First', ], ['id' => '20', 'name' => 'Second', ], ['id' => '30', 'name' => 'Third', ], ]; $collect = new Collection($arr); $keyValueArray = $collect->forSelect('name') //[ // '10' => 'First', // '20' => 'Second', // '30' => 'Third', //]

forSelectWithPrepend(string $valueName, string $keyName = 'id', array $prepend = ['' => 'Выбрать']): array, (*5)

Аналогично forSelect, только в начало массива добавляютсся данные из массива $prepend, (*6)

randomSafe (int $number = null): mixed, (*7)

Аналог стадандртного метода random, но в случае если размер коллекции меньше запрашиваемого числа элементов не выкидывается ошибка, а возвращается столько элементов сколько есть в коллекции, (*8)

php $collect = new Collection([1, 2, 3]); $randoms = $collect->randomSafe(10); echo sizeof($randoms); // 3, (*9)

Change log

Please see CHANGELOG for more information on what has changed recently., (*10)

Credits

License

The MIT License (MIT). Please see License File for more information., (*11)

The Versions

28/08 2017

dev-master

9999999-dev https://github.com/ngtfkx/laradeck-collection-macros

A set of useful Laravel collection macros

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel php collection macros ngtfkx laradeck laradeck-commands

28/08 2017

1.1.0

1.1.0.0 https://github.com/ngtfkx/laradeck-collection-macros

A set of useful Laravel collection macros

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel php collection macros ngtfkx laradeck laradeck-commands

28/08 2017

1.0.0

1.0.0.0 https://github.com/ngtfkx/laradeck-collection-macros

A set of useful Laravel collection macros

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel php collection macros ngtfkx laradeck laradeck-commands