PHPackages                             jeidison/composite-key - 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. jeidison/composite-key

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

jeidison/composite-key
======================

Laravel composite key

0.4.0(4y ago)411.7k↓25%1MITPHPPHP ^7.0|^8.0

Since Oct 22Pushed 4y ago1 watchersCompare

[ Source](https://github.com/jeidison/composite-key)[ Packagist](https://packagist.org/packages/jeidison/composite-key)[ RSS](/packages/jeidison-composite-key/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (1)Versions (7)Used By (0)

Laravel Composite Key
=====================

[](#laravel-composite-key)

==========

The problem
-----------

[](#the-problem)

Eloquent doesn't support composite keys.

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

[](#installation)

```
$ composer require jeidison/composite-key
```

Usage
-----

[](#usage)

Add Trait of your model

```
namespace App;

use Illuminate\Database\Eloquent\Model;

class MyClass extends Model
{
    use Jeidison\CompositeKey\CompositeKey;

    ...
}
```

- Find

```
    public function index()
    {
        $modelX = ModelX::find(1);
        // or
        $modelX = ModelX::find(['c1' => 1, 'c2' => 2]);
    }
```

- FindOrFail

```
    public function index()
    {
        $modelX = ModelX::findOrFail(1);
        // or
        $modelX = ModelX::findOrFail(['c1' => 1, 'c2' => 2]);
    }
```

- FindMany

```
    public function index()
    {
        $modelX = ModelX::findMany([['c1' => 1, 'c2' => 2]]);
        // or
        $modelX = ModelX::findMany([['c1' => 1, 'c2' => 2], ['a1' => 1, 'a2' => 2]]);
    }
```

- Model Fresh

```
    public function index()
    {
        $modelX      = ModelX::find(1);
        $freshModelX = $modelX->fresh();
    }
```

- Model Refresh

```
    public function index()
    {
        $anyWhatever      = Anything::find(1);
        $freshAnyWhatever = $anyWhatever->refresh();
    }
```

- Model Delete

```
    public function index()
    {
        $modelX = ModelX::find(1);
        $modelX->delete();
    }
```

- Model Destroy

```
    public function index()
    {
        $count = ModelX::destroy(['c1' => 1, 'c2' => 2]);
        // or
        $count = ModelX::destroy([['c1' => 1, 'c2' => 2], ['a1' => 1, 'a2' => 2]]);
    }
```

- FirstOrCreate

```
    $modelX = ModelX::firstOrCreate(['name' => 'Test 10']);

    $modelX = ModelX::firstOrCreate(
        ['name' => 'Test 10'],
        ['delayed' => 1, 'arrival_time' => '11:30']
    );
```

- FirstOrNew

```
    $modelX = ModelX::firstOrNew(['name' => 'Test 10']);

    $modelX = ModelX::firstOrNew(
        ['name' => 'Test 10'],
        ['delayed' => 1, 'arrival_time' => '11:30']
    );
```

- IncrementOrDecrement

```
    // Not implemented
```

- Eloquent\\Collection::find

```
    // Not implemented
```

- Eloquent\\Collection::fresh

```
    // Not implemented
```

- Authenticatable::getAuthIdentifierName

```
    // Not implemented
```

- Authenticatable::getAuthIdentifier

```
    // Not implemented
```

- Model::getRouteKey

```
    // Not implemented
```

- Model::getRouteKeyName

```
    // Not implemented
```

- SerializesAndRestoresModelIdentifiers

```
    // Not implemented
```

Authors
-------

[](#authors)

- [Jeidison Farias](https://github.com/jeidison)

License
-------

[](#license)

**composite-key** is licensed under the [MIT License](http://opensource.org/licenses/MIT).

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~138 days

Recently: every ~173 days

Total

6

Last Release

1706d ago

PHP version history (2 changes)0.1PHP &gt;=7

0.0.4PHP ^7.0|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/672f00a9bee58935e9851abc9ae1c1dfa05da76f684e08c183b5aa1ef9020e0e?d=identicon)[jeidison](/maintainers/jeidison)

---

Top Contributors

[![jeidison](https://avatars.githubusercontent.com/u/12176232?v=4)](https://github.com/jeidison "jeidison (20 commits)")

---

Tags

laravelComposite Key

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jeidison-composite-key/health.svg)

```
[![Health](https://phpackages.com/badges/jeidison-composite-key/health.svg)](https://phpackages.com/packages/jeidison-composite-key)
```

###  Alternatives

[rtconner/laravel-likeable

Trait for Laravel Eloquent models to allow easy implementation of a 'like' or 'favorite' or 'remember' feature.

394388.0k5](/packages/rtconner-laravel-likeable)[highsolutions/eloquent-sequence

A Laravel package for easy creation and management sequence support for Eloquent models with elastic configuration.

121130.3k](/packages/highsolutions-eloquent-sequence)[cybercog/laravel-nova-ban

A Laravel Nova banning functionality for your application.

40199.8k](/packages/cybercog-laravel-nova-ban)[hpolthof/laravel-translations-db

A database translations implementation for Laravel 5.

525.8k](/packages/hpolthof-laravel-translations-db)[cubettech/lacassa

Cassandra based query builder for laravel.

358.5k](/packages/cubettech-lacassa)[phaza/single-table-inheritance

Single Table Inheritance Trait

1515.8k](/packages/phaza-single-table-inheritance)

PHPackages © 2026

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