本文整理匯總了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);
}