PHPackages                             josezenem/laravel-make-migration-pivot - 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. josezenem/laravel-make-migration-pivot

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

josezenem/laravel-make-migration-pivot
======================================

Make Laravel pivot tables using the new Laravel 9 closure migrations.

1.3.2(1y ago)2077.6k—2.8%4[3 PRs](https://github.com/josezenem/laravel-make-migration-pivot/pulls)MITPHPPHP ^8.0CI passing

Since Mar 1Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/josezenem/laravel-make-migration-pivot)[ Packagist](https://packagist.org/packages/josezenem/laravel-make-migration-pivot)[ Docs](https://github.com/josezenem/laravel-make-migration-pivot)[ GitHub Sponsors](https://github.com/josezenem)[ RSS](/packages/josezenem-laravel-make-migration-pivot/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (11)Versions (12)Used By (0)

Make Laravel Pivot Tables using the new Laravel 9 closure migration format
==========================================================================

[](#make-laravel-pivot-tables-using-the-new-laravel-9-closure-migration-format)

[![Latest Version on Packagist](https://camo.githubusercontent.com/429464cf57c0abff8040125dd8b62cc47361c8cba50fc37b635f5215d28ab3c0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a6f73657a656e656d2f6c61726176656c2d6d616b652d6d6967726174696f6e2d7069766f742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/josezenem/laravel-make-migration-pivot)[![Check & fix styling](https://github.com/josezenem/laravel-make-migration-pivot/actions/workflows/php-cs-fixer.yml/badge.svg)](https://github.com/josezenem/laravel-make-migration-pivot/actions/workflows/php-cs-fixer.yml)[![Total Downloads](https://camo.githubusercontent.com/403dccd3d3cc7b73a26ed52bb9f6b980fb4e0c9d8dfc232c11324c1ca3ae1db3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a6f73657a656e656d2f6c61726176656c2d6d616b652d6d6967726174696f6e2d7069766f742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/josezenem/laravel-make-migration-pivot)

This will allow you to create pivot table migration files using the new Laravel 9 closure migration format by simply passing two models. Under the hood the system will inspect the two models to generate the pivot table and foreign key names.

```
php artisan make:pivot Category Blog
```

Will generate the following migration

```
return new class extends Migration {
    public function up()
    {
        Schema::create('blog_category', function (Blueprint $table) {
            $table->foreignIdFor(Blog::class)->constrained()->onDelete('cascade');
            $table->foreignIdFor(Category::class)->constrained()->onDelete('cascade');
            $table->primary(['blog_id', 'category_id']);

            $table->index('blog_id');
            $table->index('category_id');
        });
    }
```

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

[](#installation)

You can install the package via composer:

```
composer require josezenem/laravel-make-migration-pivot
```

Usage
-----

[](#usage)

```
php artisan make:pivot Category Blog
```

Optionally, you can publish the stubs using

```
php artisan vendor:publish --tag="laravel-make-migration-pivot-stubs"
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Jose Jimenez](https://github.com/josezenem)
- [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

Maintenance71

Regular maintenance activity

Popularity41

Moderate usage in the ecosystem

Community15

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 56.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 ~195 days

Recently: every ~207 days

Total

7

Last Release

367d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/199e41d6a1dd8442051e8a54b24af15f894d09a016cc9e80f2fb004ed7530345?d=identicon)[josezenem](/maintainers/josezenem)

---

Top Contributors

[![josezenem](https://avatars.githubusercontent.com/u/377520?v=4)](https://github.com/josezenem "josezenem (47 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] (12 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (4 commits)")[![halilcagriakkuzu](https://avatars.githubusercontent.com/u/24280215?v=4)](https://github.com/halilcagriakkuzu "halilcagriakkuzu (1 commits)")

---

Tags

laravellaravel migrationsjosezenemlaravel-make-pivotmigration pivot

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/josezenem-laravel-make-migration-pivot/health.svg)

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

###  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)
