Download the PHP package lyhty/macros without Composer
On this page you can find all versions of the php package lyhty/macros. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package macros
Short Description Helpful macros for your Laravel project.
License MIT
Homepage https://matti.suoraniemi.com/lyhty/macros
Informations about the package macros
This package provides some additional, convenient macros for you to use with your Laravel project.
Installation
Install the package with Composer:
composer require lyhty/macros
The package registers itself automatically.
Macros
Here's a brief documentation on the macros the package provides.
Illuminate\Database\Eloquent\BuilderselectKeysearchLike&orSearchLike
Illuminate\Database\Query\BuilderselectRawArr
Illuminate\Support\CollectionmergeManypick(waspluckMany)whereExtendswhereImplementswhereUses
Illuminate\Support\ArrassociatecombinefillKeysimplodezipunzip
Illuminate\Support\StrexplodeReversewrapWith
Illuminate\Support\StringableexplodeReversewrapWith
Carbon\CarbonPeriodcollect
Illuminate\Database\Eloquent\Builder
Builder::selectKey
Select the key of the model in the query (uses Model's getKey method).
Builder::searchLike & orSearchLike
⚠️ This macro relies on
Str::explodeReversemacro. If you want to disable that macro, this macro will no longer function.⚠️ The
Builder::orSearchLikemacro relies onBuilder::searchLikemacro. If you want to disable thesearchLikemacro, be sure to disable theorSearchLikemacro as well.
Illuminate\Database\Query\Builder
Builder::selectRawArr
Add raw select statements as an array, instead of as a one ugly string (selectRaw).
Illuminate\Support\Collection
Collection::mergeMany
Merge multiple arrays/collections to the collection in one go.
Collection::pick (was pluckMany)
Pick several keys from the collection items. The first value should be an array of keys you want to pick up from the collection items. The second value determines whether keys will be preserved and in which format:
PICK_WITH_FULL_KEYS (>= 2):- Keeps even the possibly nested values in their original depths.
PICK_WITH_PARTIAL_KEYS (1):- Flattens the results while keeping the keys.
PICK_WITHOUT_KEYS (0):- No keys will be preserved
Collection::whereExtends
Filter classes and/or objects that extend the given class.
Collection::whereImplements
Filter classes and/or objects that implement the given interface.
Collection::whereUses
Filter classes and/or objects that use the given trait.
Illuminate\Support\Arr
Arr::associate
Converts an array into a fully associative array by converting any values with an integer key to the value being the key filled with the given fill value. Values that have a string key already won't be touched.
Arr::combine
Similar to array_combine, but allows to have more keys than values. Keys without value will be set
as null.
Arr::fillKeys
Fills given keys with given value. You can also set that only keys that already exist in the array
can become filled. In other words, if the key foo is to be filled with value bar, but the key
foo doesn't already exist in the array, the array will remain unchanged.
Arr::implode
Implodes given array with given separator to a \Illuminate\Support\Stringable instance.
Arr::zip
Zips the key and value together with the given zipper.
Arr::unzip
Unzips keys to key and value with the given zipper.
Illuminate\Support\Str
Str::explodeReverse
Explodes the given string from the end instead of the start and returns it as
a Illuminate\Support\Collection class instance.
Str::wrapWith
Wraps the string with given character(s).
⚠️ As Laravel 9 introduced
Str::wrapmacro, as of v4.0 this macro is now calledStr::wrapWithto avoid conflicts. Note: the behavior between these two macros is different:
Illuminate\Support\Stringable
Stringable::explodeReverse
⚠️ This macro relies on
Str::explodeReversemacro. If you want to disable that macro, this macro will no longer function.
See Illuminate\Support\Str::explodeReverse
Stringable::wrapWith
⚠️ As Laravel 9 introduced
Str::wrapmacro, as of v4.0 this macro is now calledStr::wrapWithto avoid conflicts.⚠️ This macro relies on
Str::wrapWithmacro. If you want to disable that macro, this macro will no longer function.
See Illuminate\Support\Str::wrapWith
Carbon\CarbonPeriod
CarbonPeriod::collect
License
Lyhty Macros is open-sourced software licensed under the MIT license.
All versions of macros with dependencies
illuminate/support Version ^12.0 | ^13.0
illuminate/console Version ^12.0 | ^13.0
lyhty/macronite Version ^5.0
lyhty/support Version ^4.0