↧
Answer by utdev for Laravel : Traying to get property 'posts' of non-object
What is the author a separate model? First you need to create a proper migration, so that user_id is referenced as a foreign key in your posts table. You should have a migration up method similiar to...
View ArticleAnswer by Ahmad Karimi for Laravel : Traying to get property 'posts' of...
Route::get('test', function () { $user = User::where('id', 5)->with('posts')->get(); return $user; });
View ArticleLaravel : Traying to get property 'posts' of non-object
I wanted to show posts from a user. But, I received an error message : Trying to get property 'posts' of non-object User.php public function posts() { return $this->hasMany(Post::class,...
View Article