public function levelC($subsector_id) { $occupation_ids = Occupation::select('id')->where(array('subsector_id' => $subsector_id))->lists('id'); $level_C = Trainer::select(DB::raw('occupation_id, SUM(full_time_male) as male, SUM(full_time_female) as female, (SUM(full_time_male) + SUM(full_time_female)) as total'))->where('level', 'Level C')->where('report_date_id', $this->report_date_id)->where('institution_id', $this->institution_id)->whereIn('occupation_id', $occupation_ids)->get(); return $level_C; }
public function subsectors() { $sub_sectors = Subsector::whereIn('id', Occupation::select('subsector_id')->whereIn('id', Trainer::select('occupation_id')->where('report_date_id', $this->report_date_id)->where('institution_id', $this->institution_id)->distinct()->lists('occupation_id'))->distinct()->lists('subsector_id'))->get(); return $sub_sectors; }