-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
是否需要更新或爲此創建新的關係?
你爲什麼投票呢,信息不清楚?或者這個問題沒有意義。 –