本文整理汇总了PHP中Illuminate\Database\Eloquent\Model::newPivot方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::newPivot方法的具体用法?PHP Model::newPivot怎么用?PHP Model::newPivot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Eloquent\Model
的用法示例。
在下文中一共展示了Model::newPivot方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: newPivot
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);
}
示例2: newPivot
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);
}
示例3: newPivot
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);
}
示例4: newPivot
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);
}
示例5: newPivot
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);
}
示例6: newPivot
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: newPivot
/**
* 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: newPivot
/**
* 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: newPivot
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: newPivot
/**
* @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);
}