0
我有一個名爲Post
的父表,它有一個名爲is_anonymous
的布爾列。 Post
表與Users
表有關係。我只想在is_anonymous
設置爲false
時才加載此關係。有沒有辦法實現這一目標?僅當父表中的字段爲真時加載關係
以下關係爲用戶提供了所有帖子。
$institute = Institute::where('inst_id', '=', $institute_id)->with(
['posts' => function ($posts) {
$posts->with(['user', 'tags']);
}]
)->orderBy('created_at', 'DESC')->skip($skip)->take(10)->get();