mardi 1 décembre 2015

Laravel 5.1 - Relationships through two parallel pivot tables

Assume we have four tables; Matrix, Row, Column and Cell.

Matrix
  id

Row
  id
  matrix_id
  label

Column
  id
  matrix_id
  label

Cell
  id
  row_id
  column_id
  text

The relationships thus look something like

    Matrix
   /      \
  Row   Column
   \      /
     Cell

Can the relationship between Matrix and Cell through Row and Column be represented somehow in Laravel 5.1? So that I could for example have a cells() method on Matrix that returns a Relation to the cells it has through Row and Column.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire