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. [Database &amp; ORM](/categories/database)
4. /
5. ddzobov/laravel-pivot-softdeletes

ActivePackage[Database &amp; ORM](/categories/database)

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

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

2.3.1(1y ago)69567.2k↓50.4%18[6 issues](https://github.com/ddzobov/laravel-pivot-softdeletes/issues)[3 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 3d 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 93% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity52

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity65

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

486d 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.4k36.8M157](/packages/owen-it-laravel-auditing)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.4M96](/packages/mongodb-laravel-mongodb)[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.6k32.6M46](/packages/kirschbaum-development-eloquent-power-joins)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

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

Laravel relationships with support for composite/multiple keys

1.2k11.7M46](/packages/awobaz-compoships)[bavix/laravel-wallet

It's easy to work with a virtual wallet.

1.3k1.3M19](/packages/bavix-laravel-wallet)

PHPackages © 2026

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