chrisrhymes/extra-collect

A Laravel package containing a collection of collections

v0.1 2022-02-26 13:05 UTC

This package is auto-updated.

Last update: 2024-09-26 19:17:56 UTC


README

Some extra Laravel collection methods.

composer require chrisrhymes/extra-collect

Contents

Collection Methods

Prefix

collect(['a', 'b', 'c'])->prefix('test');

// ['testa', 'testb', 'testc']


collect([['name' => 'a'], ['name' => 'b'], ['name' => 'c']])->prefix('test', 'name');

// [['name' => 'testa'], ['name' => 'testb'], ['name' => 'testc']]

Suffix

collect(['a', 'b', 'c'])->suffix('test');

// ['atest', 'btest', 'ctest']


collect([['name' => 'a'], ['name' => 'b'], ['name' => 'c']])->suffix('test', 'name');

// [['name' => 'atest'], ['name' => 'btest'], ['name' => 'ctest']]

Double Quote

collect(['a', 'b', 'c'])->doubleQuote();

// ['"a"', '"b"', '"c"']


collect([['name' => 'a'], ['name' => 'b'], ['name' => 'c']])->doubleQuote('name');

// [['name' => '"a"'], ['name' => '"b"'], ['name' => '"c"']]

Testing

composer test