public function __construct($currentModel, $relatedModel, $middleTable, $currentForeignKey, $relatedForeignKey, $currentKey, $relatedKey, $middleModel = null) { $this->middleTable = $middleTable; $this->currentForeignKey = $currentForeignKey; $this->relatedForeignKey = $relatedForeignKey; $this->currentKey = $currentKey; $this->relatedKey = $relatedKey; if (is_null($middleModel)) { $this->pivot = (new Model())->table($middleTable); } else { $this->pivot = $middleModel; } parent::__construct($currentModel, $relatedModel); $this->addConstraintsForPivot(); }
public function __construct($currentModel, $relatedModel, $currentKey, $relatedKey) { $this->relatedKey = $relatedKey; $this->currentKey = $currentKey; parent::__construct($currentModel, $relatedModel); }