Download the PHP package nwidart/laravel-normalizer without Composer
On this page you can find all versions of the php package nwidart/laravel-normalizer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nwidart/laravel-normalizer
More information about nwidart/laravel-normalizer
Files in nwidart/laravel-normalizer
Package laravel-normalizer
Short Description Laravel package to normalize your data before saving into the database.
License MIT
Homepage https://github.com/nwidart/laravel-normalizer
Informations about the package laravel-normalizer
laravel-normalizer
This package helps you normalize your data in order to save them into the database. The Goal is to having separate classes that handle the data normalization, and thus can be tested independently.
Install
Via Composer
Usage
1. Adding trait
Add the Nwidart\LaravelNormalizer\Traits\CanNormalizeData
trait on the model(s) you wish data to be normalized.
2. Create Normalizer classes
Your normalizers classes need to implement the Nwidart\LaravelNormalizer\Contracts\Normalizer
interface. This interface will add the normalize(array $data)
method.
Example:
This method needs to return the $data
array. In here you can change the received data as you please.
3. Add normalizers
class property
On that same model, add a protected $normalizers
property. This is where you list your normalizers, in an array.
Example:
4. Normalize your data on save/update
Now you can start normalizing your data. This can for instance be done in your repository class.
Example:
Change log
Please see CHANGELOG for more information what has changed recently.
Testing
Contributing
Please see CONDUCT for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Nicolas Widart
- All Contributors
License
The MIT License (MIT). Please see License File for more information.