Download the PHP package free3_5man/laravel-macros without Composer
On this page you can find all versions of the php package free3_5man/laravel-macros. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download free3_5man/laravel-macros
More information about free3_5man/laravel-macros
Files in free3_5man/laravel-macros
Package laravel-macros
Short Description Extending Laravel Collection/Arr/Str/Builder/Carbon/CarbonPeriod with macros, some of Collection/Arr is inspired by prototyped.js, also with extra heper functions
License MIT
Homepage https://github.com/free3_5man/laravel-macros
Informations about the package laravel-macros
A supplement of Laravel macros and helpers
This repository contains some useful collection macros and helper functions.
Installation
You can pull in the package via composer:
The package will automatically register itself.
Macros
Collection
append
camelCaseKeys
dig
equals
ifAll
ifAny
indexOfAll
initial
kebabCaseKeys
limit
lowerCaseKeys
mapExcept
mapKeys
mapOnly
nest
offset
snakeCaseKeys
sortKeysByKeysRanking
tail
toCSV
transformKeys
whereLike
whereNotLike
zipWithKeys
Eloquent Collection
addAppends
addHidden
Query Builder
addSelectSub
filter
filterRange
filterWhereNull
overlaps
Eloquent Builder
dumpSql
enhancedPaginate
getFullSql
Arr
buildQuery
dotOnly
expand
isAssoc
isSub
parseQuery
range
remove
repeat
toObject
Str
allWords
capitalize
chars
decapitalize
each
humanize
lines
map
mask
reduce
repeat
reverse
swapCase
Carbon
getNaturalWeeks
CarbonPeriod
countWeeks
helpers
getDateTimeString
getTimestamp
formatDateTimeAssoc
Collection
append
Same with push, is a pair of prepend.
camelCaseKeys
Creates a new array from the specified assoc array, where all the keys are in camel-case.
dig
Returns the target value in a nested JSON object, based on the given key.
equals
Checks if the collection is equal to the given value.
ifAll
Returns true if the fallback function returns true for all elements in a collection,false otherwise.
ifAny
Returns true if the fallback function returns true for at least one element in a collection, false otherwise.
indexOfAll
Returns all indices of value in the array. If value never occurs, returns [].
initial
Returns all the elements of an array except the last one.
kebabCaseKeys
Creates a new array from the specified assoc array, where all the keys are in kebab-case.
limit
An alias of take.
lowerCaseKeys
Creates a new array from the specified assoc array, where all the keys are in camel-case.
mapExcept
First do high-order map, then except keys for each item.
mapKeys
First do high-order map, then only keys for each item.
mapOnly
First do high-order map, then only keys for each item.
nest
Given a flat array of objects linked to one another, it will nest them recursively.
offset
An alias of skip.
snakeCaseKeys
Creates a new array from the specified assoc array, where all the keys are in snake-case.
sortKeysByKeysRanking
Sort the collection by the keys ranking.
tail
Returns all the elements of an array except the first one.
toCSV
Converts a 2D array to a comma-separated values (CSV) string.
transformKeys
Transform only keys, values unchanged.
whereLike
Filter with regex.
whereNotLike
Reject with regex.
zipWithKeys
Given an array of valid property identifiers and an array of values, return an object associating the properties to the values. Similar but not same with collection method: combine.
Eloquent Collection
addAppends
Append attributes for each model in the collection.
addHidden
Make the hidden attributes for each model in the collection.
Query Builder
addSelectSub
Add a subquery as a column to the query.
filter
Filter using whereIn or where with the request input data or specified data.
filterRange
Filter using where or whereDate with the ranged request input data or specified data.
filterWhereNull
Filter using whereNull with the request input data or specified data.
overlaps
Filter overlaps with the given period.
Eloquent Builder
dumpSql
Dump sql with bindings.
enhancedPaginate
Enhance the existing paginate method with a map function and a given total number.
getFullSql
Get full sql string with bindings.
Arr
buildQuery
Build URL-encoded http query string.
dotOnly
Returns only the specified key / value pairs from a deeply nested array using "dot" notation.
expand
Expand the flattened dot key array to multi-dimensional array. Has the reverse effect with the existing method Arr::dot($array).
isAssoc
Judge a var is a assoc array.
isSub
Judge an array is subset of another array.
parseQuery
Parse the URL-encoded query string to array.
range
Initializes an array containing the numbers in the specified range where start and end are inclusive with there common difference step.
remove
Remove an element or elements from array.
repeat
Initializes and fills an array with the specified value.
toObject
Convert an assoc array to an object, else null.
Str
allWords
Converts a given string into an array of words with some pattern.
capitalize
Returns the capitalized string.
chars
Returns an array of the string’s character.
decapitalize
Returns the decapitalized string.
each
Just like collection each.
humanize
Converts an underscored, camelized, or dasherized string into a humanized one. Also removes beginning and ending whitespace.
lines
Splits a multiline string into an array of lines.
map
Just like collection map.
mask
Replaces part of string with the specified mask character.
reduce
Just like collection reduce.
repeat
Initializes and fills an string with the specified value.
reverse
Reverses the string.
swapCase
Returns a copy of the string in which all the case-based characters have had their case swapped.
Carbon
getNaturalWeeks
Get natural weeks array of this week, each item in this array has the week start date and the week end date. Assume monday is a week start while sunday is a week end.
CarbonPeriod
countWeeks
Count natural weeks in a period, just same as calculate the sundays count. Assume monday is a week start while sunday is a week end.
helpers
getDateTimeString
Get the specified formatted datetime string of a variable.
getTimestamp
Get the timestamp of a variable.
formatDateTimeAssoc
Format the assoc to specified format with keys.
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.