How can I create a Many to Many relationships using the custom polymorphic table?
model_has_tags
$table->increments('id');
$table->integer('tag_id';
$table->string('model_type');
$table->integer('model_id');
tags
$table->increments('id');
$table->string('name');
user
$table->increments('id');
$table->string('full_name');
I try this but not working. Tag Model
public function users()
{
return $this->morphedByMany(User::class, 'model')->using(ModelHasTags::class);
}
User Model
public function tags()
{
return $this->morphToMany(Tag::class, 'model')->using(ModelHasTags::class);
}
error :
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'stormport.models' doesn't exist (SQL: select `tags`.*, `models`.`model_id` as `pivot_model_id`, `models`.`tag_id` as `pivot_tag_id`....
How to solve this?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire