PHPackages                             ngtfkx/laradeck-collection-macros - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ngtfkx/laradeck-collection-macros

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ngtfkx/laradeck-collection-macros
=================================

A set of useful Laravel collection macros

1.1.0(8y ago)110MITPHPPHP ~5.6|~7.0

Since Aug 28Pushed 8y ago1 watchersCompare

[ Source](https://github.com/ngtfkx/laradeck-collection-macros)[ Packagist](https://packagist.org/packages/ngtfkx/laradeck-collection-macros)[ Docs](https://github.com/ngtfkx/laradeck-collection-macros)[ RSS](/packages/ngtfkx-laradeck-collection-macros/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

laradeck-collection-macros
==========================

[](#laradeck-collection-macros)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d355bb94649e5641d61fbd33c0f1f4c12005b884089c5770bcf966f80c14f643/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e6774666b782f6c6172616465636b2d636f6c6c656374696f6e2d6d6163726f732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ngtfkx/laradeck-collection-macros)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Coverage Status](https://camo.githubusercontent.com/fa2242130a5728b5d1ee8139f59b05614a6b3534fd529d54e5489637d7098290/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6e6774666b782f6c6172616465636b2d636f6c6c656374696f6e2d6d6163726f732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/ngtfkx/laradeck-collection-macros/code-structure)[![Quality Score](https://camo.githubusercontent.com/ba721889e6c92b5b861a39550d604c85b52f7129f4b25dbcefe8701348838590/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6e6774666b782f6c6172616465636b2d636f6c6c656374696f6e2d6d6163726f732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/ngtfkx/laradeck-collection-macros)[![Total Downloads](https://camo.githubusercontent.com/b38d9d32d9857a8ebc9ba7b8155da25672257bcc140d5b18d68817a3c656a68b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e6774666b782f6c6172616465636b2d636f6c6c656374696f6e2d6d6163726f732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ngtfkx/laradeck-collection-macros)

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

Install
-------

[](#install)

Via Composer

```
$ composer require ngtfkx/laradeck-collection-macros
```

Documentation
-------------

[](#documentation)

**forSelect(string $valueName, string $keyName = 'id'): array**

Метод возвращает ассоциативный массив, где в качестве ключа используется свойство `$keyName` элемента коллекции, а в качестве значения свойство `$valueName`.

```
$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 = \['' =&gt; 'Выбрать'\]): array**

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

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

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

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

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Credits
-------

[](#credits)

- [Denis Sandal](https://github.com/:author_username)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

3180d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/88ffb7c9f3e09555ebe86802abaee7c8594694b649e3409c5d475f247336ff82?d=identicon)[ngtfkx](/maintainers/ngtfkx)

---

Top Contributors

[![ngtfkx](https://avatars.githubusercontent.com/u/5647351?v=4)](https://github.com/ngtfkx "ngtfkx (5 commits)")

---

Tags

phplaravelcollectionmacrosngtfkxlaradecklaradeck-commands

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/ngtfkx-laradeck-collection-macros/health.svg)

```
[![Health](https://phpackages.com/badges/ngtfkx-laradeck-collection-macros/health.svg)](https://phpackages.com/packages/ngtfkx-laradeck-collection-macros)
```

###  Alternatives

[monicahq/laravel-cloudflare

Add Cloudflare ip addresses to trusted proxies for Laravel.

3372.7M4](/packages/monicahq-laravel-cloudflare)[kra8/laravel-snowflake

Snowflake for Laravel and Lumen.

188402.3k6](/packages/kra8-laravel-snowflake)[werxe/laravel-collection-macros

Custom Laravel Collection macros.

2625.8k](/packages/werxe-laravel-collection-macros)[bezhansalleh/filament-google-analytics

Google Analytics integration for FilamentPHP

205144.8k5](/packages/bezhansalleh-filament-google-analytics)[laragear/preload

Effortlessly make a Preload script for your Laravel application.

119363.5k](/packages/laragear-preload)[lazerg/laravel-enum-pro

A powerful PHP enum extension with collection support, random selection, and magic static calls

4319.0k](/packages/lazerg-laravel-enum-pro)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
