Last Updated | | Ratings | | Unique User Downloads | | Download Rankings |
2021-03-25 (24 days ago) | | Not yet rated by the users | | Total: 30 This week: 2 | | All time: 10,153 This week: 148 |
|
Description | | Author |
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. Innovation Award
March 2021
Nominee
Vote |
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.
Manuel Lemos |
| |
|
|
Innovation award
Nominee: 5x |
|
Details
Eloquent Composite Key
Package to enable composite key support on Eloquent Models.
Installation
Install it with composer:
composer require thiagoprz/eloquent-composite-key
Usage
Define the primaryKey as an array and use the HasCompositeKey trait on your model.
class User extends Model
{
use HasCompositeKey;
...
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.