Composite keys in Laravel can be defined by adding a property in your model named $primaryKey that specifies an array of columns. For example:0
class Order extends Model
{
protected $primaryKey = ['customer_id', 'product_id'];
// ...
}
It's important to note that this feature is not supported by all database systems, for example, MySQL does not support composite keys, but PostgreSQL does.
Tags:
laravel