Heim  >  Artikel  >  Backend-Entwicklung  >  laravel的YourCustomPivot怎么玩?

laravel的YourCustomPivot怎么玩?

WBOY
WBOYOriginal
2016-06-06 20:17:431299Durchsuche

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

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

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn