How to fix error Base table or view not found: 1146 Table laravel relationship table?
It seems Laravel is trying to use category_posts
table (because of many-to-many relationship). But you don't have this table, because you've created category_post
table. Change name of the table to category_posts
.
Laravel tries to guess the name of the table, you have to specify it directly so that it does not give you that error..
Try this:
class NameModel extends Model {
public $table = 'name_exact_of_the_table';
I hope that helps!
Schema::table
is to modify an existing table, use Schema::create
to create new.