PHPackages                             laimoon/model-updater - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. laimoon/model-updater

AbandonedArchivedLibrary[Framework](/categories/framework)

laimoon/model-updater
=====================

Laravel Model Updater

v1.0.1(6y ago)40111MITPHPPHP ^7.1

Since Jul 3Pushed 4y ago1 watchersCompare

[ Source](https://github.com/laimoon-company/laravel-model-updater)[ Packagist](https://packagist.org/packages/laimoon/model-updater)[ Docs](https://github.com/laimoon/laravel-model-updater)[ RSS](/packages/laimoon-model-updater/feed)WikiDiscussions master Synced today

READMEChangelog (8)Dependencies (1)Versions (10)Used By (0)

Laravel Model Updater
=====================

[](#laravel-model-updater)

- [Overview](#overview)
- [Installation &amp; Usage](#installation--usage)
- [Contributing](#contributing)
- [Security](#security)
- [Credits](#credits)
- [License](#license)

Overview
--------

[](#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!

```
class UserController extends Controller
{
    public function update(Request $request)
    {
        $user = auth()->user();

        // now you check for every field you allowed to update and perform the needed logic.
        if($request->has('name')) {
            // needed logic and validation
            ...
            ..
            $user->name = $request->name
        }

        if($request->has('email')) {
            // needed logic and validation
            ...
            ..
            $user->email = $request->email
        }

        // update/save the model
        $user->save();

        // return a response
        return response()->json();
    }
}
```

> New Way (Simpler)

```
//App/Http/Controllers
use App\Updaters\UserUpdater;

class UserController extends Controller
{
    public function store(UserUpdater $updates)
    {
        auth()->user()->fillUpdates($updates);
    }
}

// App/Updaters
class UserUpdater extends Updater
{
    /**
     * Allowed fields to be updated.
     */
    protected $fields = ['name', 'email'];

    protected function name($value)
    {
        $this->request->validate(['name' => 'required|string|min:6']);

        $this->model->name = $value;
    }

    protected function email($value)
    {
        $this->request->validate(['email' => 'required|string|min:6']);

        $this->model->email = $value;
    }
}
```

Installation &amp; Usage
------------------------

[](#installation--usage)

1. Install the package via composer:

> This package supports Laravel 5.5+ only

```
composer require laimoon/model-updater
```

2. Add `Updatable` trait to your desired model:

```
use Laimoon\UpdatableModel\Traits\Updateable;

class User extends Authenticatable
{
    use Updateable;
}
```

3. Make a new model updater:

```
php artisan make:updater User
```

This command will generate a new directory under `app` with namespace of `Updaters` and a file inside it called (in this example) `UserUpdater.php`.

4. Make use in your controllers:

```
use App\Updaters\UserUpdater;

class UserController extends Controller
{
    public function store(UserUpdater $updates)
    {
        auth()->user()->fillUpdates($updates);

        return response()->json();
    }
}
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Saleem Hadad](https://github.com/saleem-hadad)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~23 days

Recently: every ~46 days

Total

9

Last Release

2319d ago

Major Versions

v0.5 → v1.02019-12-25

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12780866?v=4)[Saleem Hadad سليم حداد](/maintainers/saleem-hadad)[@saleem-hadad](https://github.com/saleem-hadad)

---

Top Contributors

[![saleem-hadad](https://avatars.githubusercontent.com/u/12780866?v=4)](https://github.com/saleem-hadad "saleem-hadad (43 commits)")

---

Tags

laravellaravel-model-updaterlaimoon

### Embed Badge

![Health badge](/badges/laimoon-model-updater/health.svg)

```
[![Health](https://phpackages.com/badges/laimoon-model-updater/health.svg)](https://phpackages.com/packages/laimoon-model-updater)
```

###  Alternatives

[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k96.9M672](/packages/laravel-socialite)[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.2k84.2M224](/packages/laravel-horizon)[laravel/ui

Laravel UI utilities and presets.

2.7k134.9M597](/packages/laravel-ui)[laravel/sail

Docker files for running a basic Laravel application.

1.9k186.9M1.0k](/packages/laravel-sail)[laravel/jetstream

Tailwind scaffolding for the Laravel framework.

4.1k19.8M136](/packages/laravel-jetstream)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M256](/packages/laravel-dusk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
