mpociot / laravel-composite-key by mpociot

Support composite keys in your laravel app.
44,348
35
1
Package Data
Maintainer Username: mpociot
Maintainer Contact: m.pociot@gmail.com (Marcel Pociot)
Package Create Date: 2016-05-17
Package Last Update: 2020-11-18
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2025-10-07 15:17:34
Package Statistics
Total Downloads: 44,348
Monthly Downloads: 39
Daily Downloads: 2
Total Stars: 35
Total Watchers: 1
Total Forks: 5
Total Open Issues: 2

Laravel Composite Key Trait

This is a small trait that I use in my projects, if I need support for composite keys in my Eloquent models.

Install via composer:

composer require mpociot/laravel-composite-key

Then use the trait in your model:

class MyModel extends Model
{
    use HasCompositeKey;

    protected $primaryKey = ['foo', 'bar'];

}