Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
286 views
in Technique[技术] by (71.8m points)

php - SQLSTATE[42S02]: Base table or view not found: 1146 Table doesn't exist


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Looking at your posts migration, the category relationship in your Post model should be belongsTo not belongsToMany:

public function category()
{
    return $this->belongsTo(Category::class);
}

BelongsToMany is a many-to-many relationship which requires an intermediate (pivot) table to link the two resources.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...