芝麻web文件管理V1.00
编辑当前文件:/home/mgatv524/public_html/edurocha/vendor/illuminate/database/Eloquent/Relations/MorphToMany.php
inverse = $inverse; $this->morphType = $name.'_type'; $this->morphClass = $inverse ? $query->getModel()->getMorphClass() : $parent->getMorphClass(); parent::__construct($query, $parent, $table, $foreignKey, $otherKey, $relationName); } /** * Set the where clause for the relation query. * * @return $this */ protected function setWhere() { parent::setWhere(); $this->query->where($this->table.'.'.$this->morphType, $this->morphClass); return $this; } /** * Add the constraints for a relationship count query. * * @param \Illuminate\Database\Eloquent\Builder $query * @param \Illuminate\Database\Eloquent\Builder $parent * @param array|mixed $columns * @return \Illuminate\Database\Eloquent\Builder */ public function getRelationQuery(Builder $query, Builder $parent, $columns = ['*']) { $query = parent::getRelationQuery($query, $parent, $columns); return $query->where($this->table.'.'.$this->morphType, $this->morphClass); } /** * Set the constraints for an eager load of the relation. * * @param array $models * @return void */ public function addEagerConstraints(array $models) { parent::addEagerConstraints($models); $this->query->where($this->table.'.'.$this->morphType, $this->morphClass); } /** * Create a new pivot attachment record. * * @param int $id * @param bool $timed * @return array */ protected function createAttachRecord($id, $timed) { $record = parent::createAttachRecord($id, $timed); return Arr::add($record, $this->morphType, $this->morphClass); } /** * Create a new query builder for the pivot table. * * @return \Illuminate\Database\Query\Builder */ protected function newPivotQuery() { $query = parent::newPivotQuery(); return $query->where($this->morphType, $this->morphClass); } /** * Create a new pivot model instance. * * @param array $attributes * @param bool $exists * @return \Illuminate\Database\Eloquent\Relations\Pivot */ public function newPivot(array $attributes = [], $exists = false) { $pivot = new MorphPivot($this->parent, $attributes, $this->table, $exists); $pivot->setPivotKeys($this->foreignKey, $this->otherKey) ->setMorphType($this->morphType) ->setMorphClass($this->morphClass); return $pivot; } /** * Get the foreign key "type" name. * * @return string */ public function getMorphType() { return $this->morphType; } /** * Get the class name of the parent model. * * @return string */ public function getMorphClass() { return $this->morphClass; } }