-2
私のデータベースには2つのテーブルがあります。投稿を作成したすべてのユーザーのリストを取得する方法
Users
id,name
Posts
id,user_id,name
// user_id is the id who has created the post.
How do i get list of all users that have created the posts.
Relation in users table is like this.
=> user HasMany posts.
The relation in Post Class
=> post belongsTo users.
What i have tried so far
$uses = User::with('posts')->get();
This returns list of all users,that has not even created the post
このために新しい関係を更新する必要がありますか?
なぜ投票したのですか?情報が不明ですか?質問が理にかなっていない。 –