0
方法,我有以下關係成立:不能使用附加()在laravel
public function notes()
{
return $this->belongsToMany(Note::class);
}
public function tags()
{
return $this->belongsToMany(Tag::class);
}
和數據透視表是這樣的:
Schema::create('note_tag', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->integer('note_id')->unsigned()->index();
$table->foreign('note_id')->references('id')->on('tags')->onDelete('cascade')->onUpdate('cascade');
$table->integer('tag_id')->unsigned()->index();
$table->foreign('tag_id')->references('id')->on('notes')->onDelete('cascade')->onUpdate('cascade');
});
現在
,我使用attach()方法:
$note->tags()->attach($tagsIds);
但這不起作用,我得到這個錯誤:
[Symfony\Component\Debug\Exception\FatalErrorException] Cannot instantiate interface phpDocumentor\Reflection\DocBlock\Tag
非常感謝你 – narges