PHPackages                             totov/laravel-soft-delete-morph-to-many-pivots - 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. totov/laravel-soft-delete-morph-to-many-pivots

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

totov/laravel-soft-delete-morph-to-many-pivots
==============================================

Allow morphToMany relationship pivots to be soft deleted.

v2.0.0(5mo ago)318.4k↓13%MITPHPPHP ^8.2CI passing

Since Oct 17Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/totov/laravel-soft-delete-morph-to-many-pivots)[ Packagist](https://packagist.org/packages/totov/laravel-soft-delete-morph-to-many-pivots)[ Docs](https://github.com/totov/laravel-soft-delete-morph-to-many-pivots)[ RSS](/packages/totov-laravel-soft-delete-morph-to-many-pivots/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (12)Versions (17)Used By (0)

Allow morphToMany relationship pivots to be soft deleted.
=========================================================

[](#allow-morphtomany-relationship-pivots-to-be-soft-deleted)

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

[](#installation)

You can install the package via composer:

```
composer require totov/laravel-soft-delete-morph-to-many-pivots
```

Usage
-----

[](#usage)

Use the `MorphToManySoftDeletesTrait` trait along with the `morphToManySoft` function and which returns a `MorphToManySoftDeletes`

```
use Illuminate\Database\Eloquent\Model;
use Totov\LaravelSoftDeleteMorphToManyPivots\MorphToManySoftDeletes;
use Totov\LaravelSoftDeleteMorphToManyPivots\Traits\MorphToManySoftDeletesTrait;

class User extends Model
{
    use MorphToManySoftDeletesTrait;

    public function user_types(): MorphToManySoftDeletes
    {
        return $this->morphToManySoft(UserType::class, 'types');
    }
}
```

On the morphed model, use the `morphedByManySoft` function:

```
use Illuminate\Database\Eloquent\Model;
use Totov\LaravelSoftDeleteMorphToManyPivots\MorphToManySoftDeletes;
use Totov\LaravelSoftDeleteMorphToManyPivots\Traits\MorphToManySoftDeletesTrait;

class UserType extends Model
{
    use MorphToManySoftDeletesTrait;

    public function users(): MorphToManySoftDeletes
    {
        return $this->morphedByManySoft(User::class, 'types');
    }
}
```

Ensure that your pivot table has a `deleted_at` column which can be used for the soft deleting.

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)

- [Stephen Hamilton](https://github.com/totov)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance80

Actively maintained with recent releases

Popularity31

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 73.6% 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 ~70 days

Recently: every ~192 days

Total

12

Last Release

174d ago

Major Versions

v1.0.10 → v2.0.02025-11-25

PHP version history (2 changes)v1.0.0PHP ^8.1

v2.0.0PHP ^8.2

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

laraveltotovlaravel-soft-delete-morph-to-many-pivots

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/totov-laravel-soft-delete-morph-to-many-pivots/health.svg)

```
[![Health](https://phpackages.com/badges/totov-laravel-soft-delete-morph-to-many-pivots/health.svg)](https://phpackages.com/packages/totov-laravel-soft-delete-morph-to-many-pivots)
```

###  Alternatives

[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[spatie/laravel-model-flags

Add flags to Eloquent models

4301.1M1](/packages/spatie-laravel-model-flags)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[spatie/laravel-sql-commenter

Add comments to SQL queries made by Laravel

1931.4M1](/packages/spatie-laravel-sql-commenter)[spatie/laravel-deleted-models

Automatically copy deleted records to a separate table

409109.8k4](/packages/spatie-laravel-deleted-models)[wnx/laravel-backup-restore

A package to restore database backups made with spatie/laravel-backup.

203330.1k2](/packages/wnx-laravel-backup-restore)

PHPackages © 2026

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