newPivot() public method

Create a new pivot model instance.
public newPivot ( Model $parent, array $attributes, string $table, boolean $exists, string | null $using = null ) : Illuminate\Database\Eloquent\Relations\Pivot
$parent Model
$attributes array
$table string
$exists boolean
$using string | null
return Illuminate\Database\Eloquent\Relations\Pivot
コード例 #1
3
ファイル: Product.php プロジェクト: esclapes/foodhub.es
 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);
 }
コード例 #2
0
ファイル: Employee.php プロジェクト: rosemalejohn/hpo-hris
 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);
 }
コード例 #3
0
ファイル: Event.php プロジェクト: grit45/Clan
 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);
 }
コード例 #4
0
ファイル: Subject.php プロジェクト: evsign/laravelpivotissue
 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);
 }
コード例 #5
0
 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);
 }
コード例 #6
0
ファイル: Server.php プロジェクト: genee-projects/snail
 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);
 }
コード例 #7
0
ファイル: Privilage.php プロジェクト: AdaptiveAds/AdaptiveAds
 /**
  * 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);
 }
コード例 #8
0
ファイル: Model.php プロジェクト: artissant/laravel
 /**
  * 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);
 }
コード例 #9
0
ファイル: Book.php プロジェクト: b3it/gnucash-eloquent
 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);
 }
コード例 #10
0
ファイル: Permission.php プロジェクト: renanpro03/defender
 /**
  * @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);
 }