PHPackages                             slashequip/laravel-patchable - 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. [API Development](/categories/api)
4. /
5. slashequip/laravel-patchable

ActiveLibrary[API Development](/categories/api)

slashequip/laravel-patchable
============================

Laraval package to add a more declarative way to handle PATCH endpoints.

v1.0.0(1y ago)391[4 PRs](https://github.com/slashequip/laravel-patchable/pulls)MITPHPPHP ^8.2CI passing

Since Apr 27Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/slashequip/laravel-patchable)[ Packagist](https://packagist.org/packages/slashequip/laravel-patchable)[ Docs](https://github.com/slashequip/laravel-patcher)[ RSS](/packages/slashequip-laravel-patchable/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (11)Versions (6)Used By (0)

Laravel Patchable 🩹
===================

[](#laravel-patchable-)

[![Latest Version on Packagist](https://camo.githubusercontent.com/e786f60a6fadbc231ec9390e62971ce57585df39908e9bcfb36c2e57b9e8f372/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736c61736865717569702f6c61726176656c2d706174636865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/slashequip/laravel-patcher)[![GitHub Tests Action Status](https://camo.githubusercontent.com/2856f13b63e22ab2595e8dc7cc7e2d6fb5f0870e7264abc920cc099cb347c95f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f736c61736865717569702f6c61726176656c2d706174636865722f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/slashequip/laravel-patcher/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/92b46fb6e2273b9662896229da8e6614ebc39ec9c64b5e162bc88b0d7e1cf05d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f736c61736865717569702f6c61726176656c2d706174636865722f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/slashequip/laravel-patcher/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/ee2d872d6565ebec8da2cffd76bb7e4811307f01d4330551fbc60142619e1767/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736c61736865717569702f6c61726176656c2d706174636865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/slashequip/laravel-patcher)

Laravel Patchable is an opinionated, declarative package to help simplify the building of PATCH routes.

It abstracts the boiler plate needed to validate and update individual Model attributes based on the request.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require slashequip/laravel-patchable
```

Usage
-----

[](#usage)

Your Model's can be made patchable by add the trait of the same name.

```
use SlashEquip\Patchable\Traits\Patchable;

class Property extends Model
{
    use Patchable;
}
```

In your patch controllers you can simply call patch on the Model.

```
class UpdatePropertyController
{
    public function __invoke(Property $property)
    {
        $property->patch();
    }
}
```

To configure you model you need to define your patchable attributes.

```
class Property extends Model
{
    public $patchable = [
        'name',
        'lat',
        'lng',
    ];
}
```

To get a little more advanced you can define validation for your patchable attributes.

This can be achieved either with Laravel's string or array syntax for validation rules.

```
class Property extends Model
{
    public $patchable = [
        'name' => 'string|max:255',
        'lat' => [
            'numeric',
            'regex:/^[-]?((([0-8]?[0-9])(\.[0-9]+)?)|90(\.0+)?)$/',
        ],
        'lng' => [
            'numeric',
            'regex:/^[-]?((([0-9]|1[0-7][0-9])(\.[0-9]+)?)|180(\.0+)?)$/',
        ],
    ];
}
```

To get even more advanced you can use Patch classes for your patchable attributes.

```
class Property extends Model
{
    public $patchable = [
        'name' => PropertyNamePatch::class,
    ];
}
```

```
use SlashEquip\Patchable\Contracts\Patch;

class PropertyNamePatch implements Patch
{
    public function authorize(Property $property): bool
    {
        return true;
    }

    public function rules(): string|array
    {
        return [
            'string',
            'max:255',
        ];
    }

    public function patch(Property $property, string $key, $value): void
    {
        $property->name = strtolower($value);
    }
}
```

If you want to handle patching with a more manual approach, you can use the Patcher class directly.

```
use SlashEquip\Patchable\Patcher;

class UpdatePropertyController
{
    public function __invoke(Property $property)
    {
        Patcher::patch(
            model: $property,
            patchable: [
                'name' => PropertyNamePatch::class,
                'lat' => [
                    'numeric',
                    'regex:/^[-]?((([0-8]?[0-9])(\.[0-9]+)?)|90(\.0+)?)$/',
                ],
                'lng' => [
                    'numeric',
                    'regex:/^[-]?((([0-9]|1[0-7][0-9])(\.[0-9]+)?)|180(\.0+)?)$/',
                ],
            ],
            attributes: request()->all(),
        )->finally(function (Property $property) {
            $property->save();
        });
    }
}
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

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

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Sam Jones](https://github.com/slashequip)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

42

—

FairBetter than 89% of packages

Maintenance78

Regular maintenance activity

Popularity17

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 60% 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

Unknown

Total

1

Last Release

377d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fbb854e09eb0aafbd7b8dc4517599ced8da6b8528c9d4ddfe82a4fc9691e8796?d=identicon)[slashequip](/maintainers/slashequip)

---

Top Contributors

[![slashequip](https://avatars.githubusercontent.com/u/2316916?v=4)](https://github.com/slashequip "slashequip (9 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")

---

Tags

laravelslashequiplaravel-patcher

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/slashequip-laravel-patchable/health.svg)

```
[![Health](https://phpackages.com/badges/slashequip-laravel-patchable/health.svg)](https://phpackages.com/packages/slashequip-laravel-patchable)
```

###  Alternatives

[andreaselia/laravel-api-to-postman

Generate a Postman collection automatically from your Laravel API

1.0k586.2k3](/packages/andreaselia-laravel-api-to-postman)[mll-lab/laravel-graphiql

Easily integrate GraphiQL into your Laravel project

683.2M9](/packages/mll-lab-laravel-graphiql)[scalar/laravel

Render your OpenAPI-based API reference

6183.9k2](/packages/scalar-laravel)[ryangjchandler/bearer

Minimalistic token-based authentication for Laravel API endpoints.

8129.8k](/packages/ryangjchandler-bearer)[combindma/laravel-facebook-pixel

Meta pixel integration for Laravel

4956.9k](/packages/combindma-laravel-facebook-pixel)[stechstudio/laravel-hubspot

A Laravel SDK for the HubSpot CRM Api

2971.0k](/packages/stechstudio-laravel-hubspot)

PHPackages © 2026

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