Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function filterQuery(Request $request){
- $age = $request->age;
- $age2 = $request->age2;
- $dataGender = $request->dataGender;
- $ethnicity = $request->ethnicity;
- $area = $request->area;
- $state = $request->state;
- $namaDUN = $request->namaDUN;
- $income = $request->income;
- $income = $request->income;
- $education = $request->education;
- $digitalInclination = $request->digitalInclination;
- $employment = $request->employment;
- $carOwnership = $request->carOwnership;
- $carOwnership2 = $request->carOwnership2;
- //join table by IC as PK
- $query = ModifiedDppr::query();
- $query->join('modified_dpprs2018_algorithm', 'modified_dpprs2018_algorithm.IC', '=', 'modified_dpprs.IC')
- ->select('id', 'First_name', 'Last_name', 'Umur', 'Phonenum', 'TarikhLahir','Negeri', 'Country', 'postcode', 'Ct', 'Jantina');
- //from table = modified_dpprs
- if(!empty($request->age)){
- $query->where('modified_dpprs.modified_dpprs.Umur','>=',$age);
- }
- if(!empty($request->age2)){
- $query->where('modified_dpprs.modified_dpprs.Umur','<=',$age2);
- }
- if(!empty($request->dataGender)){
- $query->whereIn('modified_dpprs.Jantina',$dataGender); //multiselect whereIn
- }
- if(!empty($request->ethnicity)){
- $query->whereIn('modified_dpprs.Bangsa_updated',$ethnicity);
- }
- if(!empty($request->area)){
- $query->whereIn('modified_dpprs.Taman_area',$area);
- }
- if(!empty($request->state)){
- $query->whereIn('modified_dpprs.Negeri',$state);
- }
- if(!empty($request->namaDUN)){
- $query->whereIn('modified_dpprs.namaDUN',$namaDUN);
- }
- //from table = modified_dpprs2018_algorithm
- if(!empty($request->income)){
- $query->whereIn('modified_dpprs2018_algorithm.income_latest',$income);
- }
- if(!empty($request->education)){
- $query->whereIn('modified_dpprs2018_algorithm.Education',$education);
- }
- if(!empty($request->digitalInclination)){
- $query->whereIn('modified_dpprs2018_algorithm.digital_inclination',$digitalInclination);
- }
- if(!empty($request->employment)){
- $query->whereIn('modified_dpprs2018_algorithm.Employment',$employment);
- }
- if(!empty($request->carOwnership)){
- $query->where('modified_dpprs2018_algorithm.prob_owncar','>=',$carOwnership);
- }
- if(!empty($request->carOwnership2)){
- $query->where('modified_dpprs2018_algorithm.prob_owncar','<=',$carOwnership2);
- }
- $data = $query->select('modified_dpprs.*')->get();
- return datatables()->of($data)->make(true);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement