Esempio n. 1
0
 /**
  * Create a new morph to many relationship instance.
  *
  * @param  \Illuminate\Database\Eloquent\Builder  $query
  * @param  \Illuminate\Database\Eloquent\Model  $parent
  * @param  string  $name
  * @param  string  $table
  * @param  string  $foreignKey
  * @param  string  $otherKey
  * @param  string  $relationName
  * @param  bool  $inverse
  * @return void
  */
 public function __construct(Builder $query, Model $parent, $name, $table, $foreignKey, $otherKey, $relationName = null, $inverse = false)
 {
     $this->inverse = $inverse;
     $this->morphType = $name . '_type';
     $this->morphClass = $inverse ? $query->getModel()->getMorphClass() : $parent->getMorphClass();
     parent::__construct($query, $parent, $table, $foreignKey, $otherKey, $relationName);
 }
 /**
  * Create a new belongs to many relationship instance.
  * Sets default ordering by $orderColumn column.
  *
  * @param Builder $query
  * @param Model   $parent
  * @param string  $table
  * @param string  $foreignKey
  * @param string  $otherKey
  * @param string  $relationName
  * @param string  $orderColumn  position column name
  */
 public function __construct(Builder $query, Model $parent, $table, $foreignKey, $otherKey, $relationName = null, $orderColumn)
 {
     $this->orderColumn = $orderColumn;
     parent::__construct($query, $parent, $table, $foreignKey, $otherKey, $relationName);
     $this->withPivot($orderColumn);
     $this->orderBy($orderColumn, 'ASC');
 }
Esempio n. 3
0
 /**
  * Create a new triple belongs to many relation.
  *
  * @param Builder $query
  * @param Model $parent
  * @param Model $third
  * @param string $table
  * @param string $foreignKey
  * @param string $otherKey
  * @param string $thirdKey
  * @param string $relationName
  */
 public function __construct(Builder $query, Model $parent, Model $third, $table, $foreignKey, $otherKey, $thirdKey, $relationName = null)
 {
     parent::__construct($query, $parent, $table, $foreignKey, $otherKey, $relationName);
     $this->thirdKey = $thirdKey;
     $this->third = $third;
     $this->pivotColumns[] = $thirdKey;
 }
Esempio n. 4
0
 /**
  * Create a new belongs to many relationship instance (CMSModel specific)
  *
  * @param  \Illuminate\Database\Eloquent\Builder $query
  * @param  \Illuminate\Database\Eloquent\Model   $parent
  * @param  string                                $table
  * @param  string                                $foreignKey
  * @param  string                                $otherKey
  * @param  string                                $relationName
  * @param  int                                   $fromFieldId
  */
 public function __construct(Builder $query, Model $parent, $table, $foreignKey, $otherKey, $relationName = null, $fromFieldId = null)
 {
     $this->fromFieldId = $fromFieldId;
     if (!static::$fromFieldKey) {
         static::$fromFieldKey = config('pxlcms.relations.references.keys.field', 'from_field_id');
     }
     parent::__construct($query, $parent, $table, $foreignKey, $otherKey, $relationName);
 }
Esempio n. 5
0
 /**
  * Create a new belongs to many relationship instance.
  *
  * @param  \Illuminate\Database\Eloquent\Builder  $query
  * @param  \Illuminate\Database\Eloquent\Model  $parent
  * @param  string  $table
  * @param  string  $foreignKey
  * @param  string  $otherKey
  * @param  string  $relationName
  * @return void
  */
 public function __construct(Builder $query, Model $parent, $table, $foreignKey, $otherKey, $relationName = null)
 {
     parent::__construct($query, $parent, $table, $foreignKey, $otherKey, $relationName);
     $this->addDefinedConstraints();
 }
 /**
  * Create a new belongs to many relationship instance.
  * Sets default ordering by $orderColumn column.
  *
  * @param Builder $query
  * @param Model   $parent
  * @param string  $table
  * @param string  $foreignKey
  * @param string  $otherKey
  * @param string  $relationName
  * @param string  $orderColumn  position column name
  */
 public function __construct(Builder $query, Model $parent, $table, $foreignKey, $otherKey, $relationName = null, $orderColumn = null)
 {
     parent::__construct($query, $parent, $table, $foreignKey, $otherKey, $relationName);
     $this->setOrderColumn($orderColumn);
 }