Skip to content

Instantly share code, notes, and snippets.

/** Secret

Created August 25, 2016 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/7a2387f18bfa16680505ca5b8244bd39 to your computer and use it in GitHub Desktop.
Save anonymous/7a2387f18bfa16680505ca5b8244bd39 to your computer and use it in GitHub Desktop.
**OrdersTable***
$this->belongsToMany('Products',[
'through'=>'OrderLines',
'foreignKey'=>'order_id',
'bindingKey'=>'id',
]);
**OrderLinesTable**
$this->belongsTo('Orders', [
'foreignKey' => 'order_id'
]);
$this->belongsTo('Products',[
'foreignKey' => 'sku',
'bindingKey' => 'sku',
]);
**ProductsTable**
$this->belongsToMany('Orders',
[
'through'=>'OrderLines',
'foreignKey'=>'sku',
'bindingKey'=>'sku',
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment