https://github.com/michael-rubel/laravel-loop-functions
Collection of helper functions
https://github.com/michael-rubel/laravel-loop-functions
helper-functions laravel looking-for-contributors php
Last synced: 5 months ago
JSON representation
Collection of helper functions
- Host: GitHub
- URL: https://github.com/michael-rubel/laravel-loop-functions
- Owner: michael-rubel
- License: mit
- Archived: true
- Created: 2021-12-22T13:17:32.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-03-02T06:35:39.000Z (over 2 years ago)
- Last Synced: 2025-11-21T21:23:44.321Z (7 months ago)
- Topics: helper-functions, laravel, looking-for-contributors, php
- Language: PHP
- Homepage:
- Size: 84 KB
- Stars: 17
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README

# Laravel Loop Functions
[](https://packagist.org/packages/michael-rubel/laravel-loop-functions)
[](https://packagist.org/packages/michael-rubel/laravel-loop-functions)
[](https://scrutinizer-ci.com/g/michael-rubel/laravel-loop-functions/?branch=main)
[](https://scrutinizer-ci.com/g/michael-rubel/laravel-loop-functions/?branch=main)
[](https://github.com/michael-rubel/laravel-loop-functions/actions)
[](https://github.com/michael-rubel/laravel-loop-functions/actions)
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
[](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md)
## Installation
Install the package using composer:
```bash
composer require michael-rubel/laravel-loop-functions
```
## Usage
```php
use LoopFunctions;
```
#### Assign Eloquent model attributes to class properties:
```php
$this->propertiesFrom($model);
```
#### Assign array key values to class properties:
```php
$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:
```php
use WithDynamicProperties;
```
`Note: if you use the Livewire components, it already has similar definitions under the hood.`
#### Dump class properties:
```php
$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.
```bash
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
```bash
composer test
```
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.