michael-rubel / laravel-loop-functions
Collection of functions to loop over your data.
Fund package maintenance!
paypal.me/observername
Installs: 14 115
Dependents: 1
Suggesters: 0
Security: 0
Stars: 18
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- php: ^8.0
- illuminate/contracts: ^9.0|^10.0
- spatie/laravel-package-tools: ^1.9
Requires (Dev)
- brianium/paratest: ^6.3
- laravel/pint: ^1.0
- mockery/mockery: ^1.4.4
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0
- orchestra/testbench: ^7.0|^8.0
- phpunit/phpunit: ^9.5
- roave/backward-compatibility-check: ^7.0|^8.0
This package is auto-updated.
Last update: 2024-03-12 21:25:38 UTC
README
Laravel Loop Functions
The package provides the collection of methods to loop over your data.
The package requires PHP 8
or higher and Laravel 9
or higher.
#StandWithUkraine
Installation
Install the package using composer:
composer require michael-rubel/laravel-loop-functions
Usage
use LoopFunctions;
Assign Eloquent model attributes to class properties:
$this->propertiesFrom($model);
Assign array key values to class properties:
$this->propertiesFrom($array);
If you want to use dynamic properties, adjust the dynamic_properties
key in the config and add the following trait if your class is not already implementing the get/set
magic methods:
use WithDynamicProperties;
Note: if you use the Livewire components, it already has similar definitions under the hood.
Dump class properties:
$this->dumpProperties();
Ignored property names
By default, the package ignores id
and password
properties to avoid conflicts in Livewire/auth components.
You can customize the ignore list by editing the config.
php artisan vendor:publish --tag="loop-functions-config"
Logging
The functions don't throw an exception in case of failed assignment (e.g. type incompatibility) but log such an event. You can disable exception logging if you wish so in the config.
Testing
composer test
License
The MIT License (MIT). Please see License File for more information.