PHPackages                             ddzobov/laravel-pivot-softdeletes - 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. ddzobov/laravel-pivot-softdeletes

ActivePackage

ddzobov/laravel-pivot-softdeletes
=================================

Make your Eloquent models pivots be able to soft deleted in Laravel/Lumen

2.3.1(1y ago)69495.5k—9.3%17[6 issues](https://github.com/ddzobov/laravel-pivot-softdeletes/issues)[2 PRs](https://github.com/ddzobov/laravel-pivot-softdeletes/pulls)1MITPHPCI failing

Since Jan 20Pushed 1y ago3 watchersCompare

[ Source](https://github.com/ddzobov/laravel-pivot-softdeletes)[ Packagist](https://packagist.org/packages/ddzobov/laravel-pivot-softdeletes)[ Docs](https://github.com/ddzobov/laravel-pivot-softdeletes)[ RSS](/packages/ddzobov-laravel-pivot-softdeletes/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (15)Used By (1)

Laravel pivot SoftDeletes for Laravel 5.8 to 12.x
=================================================

[](#laravel-pivot-softdeletes-for-laravel-58-to-12x)

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

[](#installation)

Require this package with composer:

```
composer require ddzobov/laravel-pivot-softdeletes

```

Basic usage
-----------

[](#basic-usage)

```
use DDZobov\PivotSoftDeletes\Model;

class Post extends Model
{
    public function tags()
    {
        return $this->belongsToMany(Tag::class)->withSoftDeletes();
    }
}

class Tag extends Model
{
    public function posts()
    {
        return $this->belongsToMany(Post::class)->withSoftDeletes();
    }
}
```

### Custom pivot model:

[](#custom-pivot-model)

```
use DDZobov\PivotSoftDeletes\Model;
use DDZobov\PivotSoftDeletes\Relations\Pivot;

class Post extends Model
{
    public function tagsWithCustomPivot()
    {
        return $this->belongsToMany(Tag::class)->using(PostTag::class)->withSoftDeletes();
    }
}

class Tag extends Model
{
    public function postsWithCustomPivot()
    {
        return $this->belongsToMany(Post::class)->using(PostTag::class)->withSoftDeletes();
    }
}

class PostTag extends Pivot
{

}
```

### Custom deleted\_at field:

[](#custom-deleted_at-field)

```
$this->belongsToMany(Post::class)->withSoftDeletes('custom_deleted_at');
```

### Show without trashed (default behavior):

[](#show-without-trashed-default-behavior)

```
// withoutTrashed() already called inside withSoftDeletes()
$this->belongsToMany(Post::class)->withSoftDeletes();

// same behavior
$this->belongsToMany(Post::class)->withSoftDeletes()->withoutTrashedPivots();
```

### Show exists &amp; trashed:

[](#show-exists--trashed)

```
$this->belongsToMany(Post::class)->withSoftDeletes()->withTrashedPivots();
```

### Show only trashed:

[](#show-only-trashed)

```
$this->belongsToMany(Post::class)->withSoftDeletes()->onlyTrashedPivots();
```

### Restore pivot recods:

[](#restore-pivot-recods)

```
$post->tags()->restore([$tag->id]);
```

### Restore pivot recods (with custom pivot):

[](#restore-pivot-recods-with-custom-pivot)

```
$post->tagsWithCustomPivot()->restore([$tag->id]);
```

### Force detach pivot records:

[](#force-detach-pivot-records)

```
$post->tags()->forceDetach([$tag->id]);
```

### Sync with force detaching pivot records:

[](#sync-with-force-detaching-pivot-records)

```
$post->tags()->syncWithForceDetaching([$tag->id]);
```

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

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

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance42

Moderate activity, may be stable

Popularity52

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 76.9% 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 ~144 days

Recently: every ~257 days

Total

14

Last Release

439d ago

Major Versions

1.1.3 → 2.0.02020-04-30

### Community

Maintainers

![](https://www.gravatar.com/avatar/42f0f0db49d98f2f12be692065efdfedfbf19cab46e12f7dc4076ff0d1b31d0a?d=identicon)[zobov](/maintainers/zobov)

---

Top Contributors

[![ddzobov](https://avatars.githubusercontent.com/u/9539529?v=4)](https://github.com/ddzobov "ddzobov (20 commits)")[![azgooon](https://avatars.githubusercontent.com/u/26380378?v=4)](https://github.com/azgooon "azgooon (2 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (2 commits)")[![GrahamCampbell](https://avatars.githubusercontent.com/u/2829600?v=4)](https://github.com/GrahamCampbell "GrahamCampbell (1 commits)")[![jackwakefield](https://avatars.githubusercontent.com/u/893609?v=4)](https://github.com/jackwakefield "jackwakefield (1 commits)")

---

Tags

laravellumensoftdeletepivot

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ddzobov-laravel-pivot-softdeletes/health.svg)

```
[![Health](https://phpackages.com/badges/ddzobov-laravel-pivot-softdeletes/health.svg)](https://phpackages.com/packages/ddzobov-laravel-pivot-softdeletes)
```

###  Alternatives

[owen-it/laravel-auditing

Audit changes of your Eloquent models in Laravel

3.4k33.0M95](/packages/owen-it-laravel-auditing)[shiftonelabs/laravel-cascade-deletes

Adds application level cascading deletes to Eloquent Models.

163632.1k2](/packages/shiftonelabs-laravel-cascade-deletes)[altek/accountant

The auditing &amp; accountability package for Laravel's Eloquent ORM.

92954.3k4](/packages/altek-accountant)

PHPackages © 2026

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