Download the PHP package laimoon/model-updater without Composer
On this page you can find all versions of the php package laimoon/model-updater. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download laimoon/model-updater
More information about laimoon/model-updater
Files in laimoon/model-updater
Package model-updater
Short Description Laravel Model Updater
License MIT
Homepage https://github.com/laimoon/laravel-model-updater
Informations about the package model-updater
Laravel Model Updater
- Overview
- Installation & Usage
- Contributing
- Security
- Credits
- License
Overview
ModelUpdater is a package helps you define the business logic and the validation needed to update an entire model's fields or just a few of them via a simple controller action and request handler.
Let's take a simple example to illustrate the purpose of this package:
Suppose you have a user model and you have an API endpoint to update a user's fields in the database where as the API consumer can update any field individually or all at once and the problem is that each field has its own logic needed before you store the updated value to the database.
Of course, there are a lot of different ways to handle this case, let's consider this simple and common one:
Old Way
As you can see the controller's method with two fields only becomes a big one, just imagine if you have 20+ fields!
New Way (Simpler)
Installation & Usage
- Install the package via composer:
This package supports Laravel 5.5+ only
-
Add
Updatable
trait to your desired model: - Make a new model updater:
This command will generate a new directory under app
with namespace of Updaters
and a file inside it called (in this example) UserUpdater.php
.
- Make use in your controllers:
Contributing
Please see CONTRIBUTING for details.
Credits
- Saleem Hadad
- All Contributors
License
The MIT License (MIT). Please see License File for more information.