Download the PHP package wp-grogu/laravel-fluent-plus without Composer
On this page you can find all versions of the php package wp-grogu/laravel-fluent-plus. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wp-grogu/laravel-fluent-plus
More information about wp-grogu/laravel-fluent-plus
Files in wp-grogu/laravel-fluent-plus
Package laravel-fluent-plus
Short Description A fork from janpantel/laravel-fluent-plus
License MIT
Informations about the package laravel-fluent-plus
Laravel Fluent Plus
This package extends Laravel's Fluent
class to provide a
supercharged experience like type casting and recursive
Fluent access to sub-assocs.
Installation
Use composer to grep the package :
Basic usage
Instead of extending Illuminate\Support\Fluent
you extend
Grogu\FluentPlus\FluentPlus
instead. As this
class is a superset of Fluent it can be treated as a drop
in replacement.
FluentPlus
implements a $casts
property that defines
how the attributes of your assoc should be cast.
For the following example assume NamesContainer
, Price
and StockLevel
to be classes extending Fluent
or FluentPlus
as well.
The resulting object now offers convenient property access:
The problem this package solves
If you work with assocs a lot and like using property access
over assoc access Laravel's Fluent
class is a convenient
way to do so.
The use case that made me write this package is working
with responses fetched from 3rd party APIs. Since I want
to use @property
PHP docs to have "type safety" while
not manually assigning properties.
Advanced usage
Recursive array casts
FluentPlus
casts sub-assocs that do not
have a cast defined into other FluentPlus for infinite
dimension property access.
You can turn this feature off by setting the $recursive
property in your derived FluentPlus
to false
or using
the NonRecursiveFluentPlus
utility class if you want
to inline it instead.