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.1(1w ago)321.8k↓60.6%MITPHPPHP ^8.2CI passing

Since Oct 17Pushed 1w 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 2d ago

READMEChangelog (10)Dependencies (24)Versions (19)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

55

—

FairBetter than 97% of packages

Maintenance98

Actively maintained with recent releases

Popularity31

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 73.3% 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 ~82 days

Recently: every ~74 days

Total

13

Last Release

10d 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 (85 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (21 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (10 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

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k102.4M1.4k](/packages/spatie-laravel-permission)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M100](/packages/dedoc-scramble)[wnx/laravel-backup-restore

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

213420.9k2](/packages/wnx-laravel-backup-restore)[spatie/laravel-passkeys

Use passkeys in your Laravel app

471890.7k39](/packages/spatie-laravel-passkeys)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)

PHPackages © 2026

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