Download the PHP package igortrinidad/laravel-model-utilities without Composer
On this page you can find all versions of the php package igortrinidad/laravel-model-utilities. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download igortrinidad/laravel-model-utilities
More information about igortrinidad/laravel-model-utilities
Files in igortrinidad/laravel-model-utilities
Package laravel-model-utilities
Short Description A set of tools for Laravel Models
License MIT
Informations about the package laravel-model-utilities
laravel-model-utilities
A set of tools to use within your Laravel Models
1. Install
Install package
Publish de config file: model-utilities.php
2. Use the traits you need inside your models:
See the full example:
Format Currency Settings:
The key of the array $currencyColumns should be the same name of the column that will be formatted
This trait doesn't change the value of the model on saving or updating, just create the attributes 'formatted_value' and 'formatted_discount' for the model after ::retrieved the model from the database
Format Date Trait:
Add trait to the model and set the fields that should be formatted:
Uuid:
Add uuid to the ID column for the model, setting the incrementing to false
This trait use Ramsey Uuid::uuid4 the same as Laravel Str::uuid to generate the uuid
Example of migration using Uuid in Laravel
Stand-alone use
If you wish you could use the functions of ModelUtilities stand-alone too
Example of stand alone use for formatCurrency method
This output the formatted value: 'R$ 1.234,32';
Stand-alone methods availables
Author
- Igor Trindade - Developer
- github.com/igortrinidad
- https://igortrindade.dev
Tests
License
This project is licensed under the MIT License - see the LICENSE file for details.
Changelog
- v1.2.4
- Initial release.
- Added config file to code reuse for formatCurrency and formatDate methods
- Added FullName trait and function
- Added UpperCaseFirst trait and tests