Home  >  Article  >  Backend Development  >  laravel的YourCustomPivot怎么玩?

laravel的YourCustomPivot怎么玩?

WBOY
WBOYOriginal
2016-06-06 20:17:431345browse

<code>public function newPivot(Model $parent, array $attributes, $table, $exists)
{
    return new YourCustomPivot($parent, $attributes, $table, $exists);
}

class Base extends Eloquent {

public function newPivot(Eloquent $parent, array $attributes, $table, $exists)
{
     return new Membership($parent, $attributes, $table, $exists);
}

</code>

资料说这样玩,但是还是晕,各种报错

回复内容:

<code>public function newPivot(Model $parent, array $attributes, $table, $exists)
{
    return new YourCustomPivot($parent, $attributes, $table, $exists);
}

class Base extends Eloquent {

public function newPivot(Eloquent $parent, array $attributes, $table, $exists)
{
     return new Membership($parent, $attributes, $table, $exists);
}

</code>

资料说这样玩,但是还是晕,各种报错

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn