public function many_to_many(Model $reference) { $columns1 = parent::findConstraitn('PrimaryKey')->getColumns(); $columns2 = $reference->findConstraitn('PrimaryKey')->getColumns(); $mtm = ManyToMany::getInstance(parent::persistence(), $reference->persistence(), $columns1, $columns2); $this->weaks_entitys[get_class($mtm)] = $mtm; }
/** * Removes the relationship between the two sides of the many to many * (not deleting either of the actual sides of the models themselves) * * @param array $ids The identifiers to remove from the associative table * @param closure $constraint Additional constraints to place on the query * @return $this * @since 2.0.0 **/ public function disconnect($ids, $constraint = null) { $associativeTable = $this->associativeTable; $shifter = $this->shifter; $model = $this->model; parent::disconnect($ids, function ($query) use($associativeTable, $model, $shifter) { $query->whereEquals($associativeTable . '.' . $shifter, strtolower($model->getModelName())); }); return $this; }