Download the PHP package emrul1875/laravel-extra-collection without Composer
On this page you can find all versions of the php package emrul1875/laravel-extra-collection. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download emrul1875/laravel-extra-collection
More information about emrul1875/laravel-extra-collection
Files in emrul1875/laravel-extra-collection
Package laravel-extra-collection
Short Description An extra collection pacakge for Laravel
License MIT
Homepage https://github.com/emrul1875/laravel_extra_collection
Informations about the package laravel-extra-collection
Laravel Extra Collection
This is a package of Laravel Collection which can be used with laravel existing collection. You are welcome to give new idea or contribute in repository. Let's make our lives much more easier.
Installation
You can install the package via composer:
Usage
The package is auto-discovered!
Add the service provider to config/app.php
Collections
prependValue
The prependValue()
method receive 3 parameter. First 2 parameter is mandatory and 3rd parameter
is optional.First parameter receive an array or string. If your collection is sequential array
you can pass string as a first parameter otherwise pass an array. The array should contain key
and value pair where key will be the property name of collection which should be changed and value
should be the text that needs to prepend with value. You can pass true or false in thrid parameter.
By default it is false. If you pass true it will skip all property which has null value.
appendValue
The appendValue()
method receive 3 parameter. First 2 parameter is mandatory and 3rd parameter is optional.
First parameter receive an array or string. If your collection is sequential array you can pass string as a
first parameter otherwise pass an array. The array should contain key and value pair where key will be the
property name of collection which should be changed and value should be the text value that needs to append with
value. You can pass true or false in thrid parameter. By default it is false. If you pass true it will skip all
property which has null value.
concatValue
The concatValue()
method receive 3 parameter. First 2 parameter is mandatory and
3rd parameter is optional.First parameter receive new property name that should be
added in the collection. Second parameter receivesarray of field name which exist
in collection. Third parameter receives delimiter (comma ,
or space ' '
).
at
The at()
method takes an integer value and returns the item at that index, allowing for positive and negative integers. Negative integers count back from the last item in the array.
find
The find()
method returns the value of the first element in the provided array that satisfies the provided testing function. If no values satisfy the testing function, null
is returned.
findIndex
The findIndex()
method returns the index of the first element in the array that satisfies the provided testing function. Otherwise, it returns -1, indicating that no element passed the test.