Quantcast
Channel: Laravel : Traying to get property 'posts' of non-object - Stack Overflow
Browsing latest articles
Browse All 3 View Live

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 Article


Answer 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 Article


Laravel : 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
Browsing latest articles
Browse All 3 View Live


Latest Images