PHPackages                             jwohlfert23/laravel-sync-relations - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. jwohlfert23/laravel-sync-relations

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jwohlfert23/laravel-sync-relations
==================================

Package to sync nested relations from request data

5.0.0(2y ago)07.4k1[1 PRs](https://github.com/jwohlfert23/laravel-sync-relations/pulls)MITPHPPHP &gt;=8.2

Since Jan 19Pushed 2y ago1 watchersCompare

[ Source](https://github.com/jwohlfert23/laravel-sync-relations)[ Packagist](https://packagist.org/packages/jwohlfert23/laravel-sync-relations)[ RSS](/packages/jwohlfert23-laravel-sync-relations/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (10)Dependencies (6)Versions (31)Used By (0)

### Laravel Sync Relations

[](#laravel-sync-relations)

Add this to your models:

```
use Jwohlfert23/LaravelSyncRelations/SyncableTrait;
...

class Post extends Model {
    use SyncableTrait;
}
```

And you can use it in your controllers like so:

```
public function update($id) {
    $post = Post::find($id);

    $post->saveAndSync(request()->input(), ['tags']);
}
```

Let's assume the following

- Post model has a "hasMany" relationship with tags.
- The request data looks like:

```
{
  "title": "My Post Title",
  "tags": [{
    "id": 1,
    "name": "My First Tag"
  }, {
     "name": "My Second Tag"
  }]
}
```

By running `saveAndSync`, it will iterate over the 2 tags provided in the request. Because the first one already exists, it will update that one and set the name to "My First Tag". The second one doesn't exist aleady so it will create it using the name "My Second Tag". After this controller processeed this request, you could run the following:

```
Post::find($id)->tags->pluck('name')
```

and get this:

```
["My First Tag", "My Second Tag"]
```

This package also works with "belongsToMany" and "belongsTo" relationship types. However, for those, it will not update/create the nested objects. It will only associate the existing models with the parent model (in other words, for these relationship, you must provide the primary key for each child).

Additionally, you could run `saveAndSync(request()->input(), ['comments.author'])` to do a nested sync.

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 97.2% 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 ~54 days

Recently: every ~350 days

Total

29

Last Release

837d ago

Major Versions

1.4.0 → 2.0.02020-04-30

2.3.0 → 3.0.02022-02-09

3.0.0 → 4.0.02023-02-01

4.0.0 → 5.0.02024-03-19

PHP version history (3 changes)1.0.0PHP &gt;=5.5.9

3.0.0PHP &gt;=7.3

5.0.0PHP &gt;=8.2

### Community

Maintainers

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

---

Top Contributors

[![jwohlfert23](https://avatars.githubusercontent.com/u/2797531?v=4)](https://github.com/jwohlfert23 "jwohlfert23 (35 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

laravelrelationssync

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jwohlfert23-laravel-sync-relations/health.svg)

```
[![Health](https://phpackages.com/badges/jwohlfert23-laravel-sync-relations/health.svg)](https://phpackages.com/packages/jwohlfert23-laravel-sync-relations)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8793.2M25](/packages/yajra-laravel-oci8)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.6k29.9M147](/packages/laravel-cashier)[flarum/core

Delightfully simple forum software.

201.4M2.3k](/packages/flarum-core)[wearepixel/laravel-cart

A cart implementation for Laravel

1374.8k](/packages/wearepixel-laravel-cart)[api-platform/laravel

API Platform support for Laravel

58171.6k14](/packages/api-platform-laravel)

PHPackages © 2026

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