1
我想知道是否有在Laravel中使用Eloquent來寫這樣的查詢。我的意思是我可以在where子句中進行熱切加載。我從最後一天卡在這裏,我真的想這樣做。所以需要建議。在Laravel的where子句中嵌套的熱切加載
$notifications = Notification::where('user_id',Auth::user()->id)
->where('is_try', '!=', Config::get('constants.NOTIFICATION_AGAINST_JOB_TURN_DOWN'))
->where('is_try', '!=', Config::get('constants.NOTIFICATION_AGAINST_JOB_EXPIRED'))
->where(function($query) {
$query->where(function($query) {
$query->where('message', '!=', 'job_post')
->with(['suggestion' => function ($query) {
$query->with(['job' => function ($query) {
$query->with('company');
}]);
}]);
})
->orWhere(function($query){
$query->where('message','job_post')
->with(['job' => function ($query) {
$query->with('company');
}]);
});
})
->orderBy('notifications.created_at','desc')
->get();