How to get data from database in Laravel?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
20 views
Good time of day.
The user has a page where he can write posts. How can I display posts of a specific user from the DB on the page? I have posts of all users are stored in one table. Where there is 1. id-post 2. id of the user 3. the post. Trying to display user his posts, however, display all posts from all users.
by | 20 views

1 Answer

0 like 0 dislike
Laravel relationships

Users need to add the relation pointing to model posts and then posts a user can access through simple design:
$user->posts
by

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
3 answers
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
35,430 users