Create a new pivot model instance.
public function newPivot(Model $parent, array $attributes, $table, $exists) { if ($parent instanceof Order) { return new ProductPrice($parent, $attributes, $table, $exists); } return parent::newPivot($parent, $attributes, $table, $exists); }
public function newPivot(Model $parent, array $attributes, $table, $exists) { if ($parent instanceof Shift) { return new EmployeeShiftPivot($parent, $attributes, $table, $exists); } return parent::newPivot($parent, $attributes, $table, $exists); }
public function newPivot(Model $parent, array $attributes, $table, $exists) { if ($parent instanceof Member) { return new MembersEvents($parent, $attributes, $table, $exists); } return parent::newPivot($parent, $attributes, $table, $exists); }
public function newPivot(Model $parent, array $attributes, $table, $exists) { if ($parent instanceof Student) { return new StudentSubjectPivot($parent, $attributes, $table, $exists); } return parent::newPivot($parent, $attributes, $table, $exists); }
public function newPivot(Model $parent, array $attributes, $table, $exists) { if ($parent instanceof Endpoint) { return new FieldEndpoint($parent, $attributes, $table, $exists); } return parent::newPivot($parent, $attributes, $table, $exists); }
public function newPivot(Model $parent, array $attributes, $table, $exists) { if ($parent instanceof \App\Project) { return new \App\ProjectServerPivot($parent, $attributes, $table, $exists); } return parent::newPivot($this->parent, $attributes, $this->table, $exists); }
/** * Overrides default newPivot method to provide extra logic.... * REVIEW??? * @param Model $parent Parent object of pivot table * @param array $attributes Custom defined columns for pivot table * @param string $table Table name to give to the pivot * @param boolean $exists */ public function newPivot(Model $parent, array $attributes, $table, $exists) { if ($parent instanceof Department) { return new DepartmentUser($parent, $attributes, $table, $exists); } return parent::newPivot($parent, $attributes, $table, $exists); }
/** * Create a new pivot model instance. * * @param \Illuminate\Database\Eloquent\Model $parent * @param array $attributes * @param string $table * @param bool $exists * @return \Illuminate\Database\Eloquent\Relations\Pivot */ public function newPivot(EloquentModel $parent, array $attributes, $table, $exists) { $modelClass = get_class($parent); if (isset($this->pivots[$modelClass])) { $pivotClass = $this->pivots[$modelClass]; return new $pivotClass($parent, $attributes, $table, $exists); } return parent::newPivot($parent, $attributes, $table, $exists); }
public function newPivot(Model $parent, array $attributes, $table, $exists) { if ($this instanceof Transaction && $parent instanceof Account) { return new SplitPivot($parent, $attributes, $table, $exists); } if ($this instanceof Account && $parent instanceof Transaction) { return new SplitPivot($parent, $attributes, $table, $exists); } return parent::newPivot($parent, $attributes, $table, $exists); }
/** * @param Model $parent * @param array $attributes * @param string $table * @param bool $exists * * @return PermissionUserPivot|\Illuminate\Database\Eloquent\Relations\Pivot */ public function newPivot(Model $parent, array $attributes, $table, $exists) { $userModel = app()['config']->get('auth.model'); $roleModel = app()['config']->get('defender.role_model'); if ($parent instanceof $userModel) { return new PermissionUserPivot($parent, $attributes, $table, $exists); } if ($parent instanceof $roleModel) { return new PermissionRolePivot($parent, $attributes, $table, $exists); } return parent::newPivot($parent, $attributes, $table, $exists); }