首頁  >  文章  >  後端開發  >  laravel的YourCustomPivot怎么玩?

laravel的YourCustomPivot怎么玩?

WBOY
WBOY原創
2016-06-06 20:17:431300瀏覽

<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>

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

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn