public function scopeUplevel($query, $level) { $query->quiz()->whereDifficultyId(Difficulty::select('id')->orderBy('difficulty', 'asc')->first()->id)->wherein('skill_id', Skill::select('id')->whereLevelId(Level::where('level', '>', $level)->orderBy('level', 'asc')->select('id')->first()->id)->groupBy('track_id')->get())->groupBy('skill_id')->get(); }