Download the PHP package tyler36/laravel-helper-macros without Composer
On this page you can find all versions of the php package tyler36/laravel-helper-macros. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tyler36/laravel-helper-macros
More information about tyler36/laravel-helper-macros
Files in tyler36/laravel-helper-macros
Package laravel-helper-macros
Short Description Collection of Helpers and macros for Laravel
License
Informations about the package laravel-helper-macros
Laravel Helpers
Installation
1.Install package through composer.
2.Add package to config/app.php
Helpers
Validator
Inspired by Validate (almost) anything in Laravel. Uses Laravel Validator class to validate anything.
EG. Validate Date (expects FALSE):
EG. Validate Date (expects TRUE):
Macros
Collections
These macros extend collection functionality.
pipe
Inspired by The pipe collection macro. Pass collection to a function.
dd
Inspired by Debugging collections. Debug a collection by 'dump and die' the current state. Can be used mid-chain to break and dump.
ifEmpty
Run callback if collection is empty.
ifAny
Run callback if collection has data ( >1 item).
mapToAssoc
Convert collection to associative array Inspired by Customizing Keys When Mapping Collections
Response
These macros help to standardize api json response returns throughout the application. Inspired by Laravel Response Macros for APIs
Success
Returns payload ($data) with a HTTP status code 200
EG.
Returns HTTP status 200 with the following:
noContent
Returns empty content with a HTTP status code 402
Error
Returns message ($message) content with an optional HTTP status code ($statusCode) [Default: HTTP status code 400]
Eg.
Returns HTTP status 400 with the following:
Eg.
Returns HTTP status 403 with the following: