|Ratings|| ||Unique User Downloads|| ||Download Rankings|
|Not yet rated by the users||Total: 41 ||All time: 10,527 This week: 189|
This package can be used to define object properties to use as primary keys.
It provides a trait that can be used in Laravel model classes to define multiple properties that will be used as primary keys.
The names of the primary key properties should be defined in model classes as an array assigned to a primary class protected class variable.
|Usually applications that database tables to store information, define one field that has unique values in all records to be the key to access the record data faster.
However, in certain applications there is the need to use more than one table field as unique value key to access the table records faster.
This package provides a trait that can be used with Laravel model objects to define which fields will be used as primary keys composed with values of more than one field.
Eloquent Composite Key
Package to enable composite key support on Eloquent Models.
Install it with composer:
composer require thiagoprz/eloquent-composite-key
Define the primaryKey as an array and use the HasCompositeKey trait on your model.
class User extends Model
protected $primaryKey = ['firstKey', 'secondKey'];
The idea of this package is to allow eloquent models to use composite keys despite that Eloquent doesn't support it officially (see https://laravel.com/docs/8.x/eloquent#composite-primary-keys).
||Applications that use this package
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.