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_dppr2018_algorithm', 'modified_dppr2018_algorithm.IC', '=', 'modified_dppr2018.IC');
- //from table = modified_dpprs
- if(!empty($request->age)){
- $query->where('modified_dppr2018.Umur','>=',$age);
- }
- if(!empty($request->age2)){
- $query->where('modified_dppr2018.Umur','<=',$age2);
- }
- if(!empty($request->dataGender)){
- $query->whereIn('modified_dppr2018.Jantina',$dataGender); //multiselect whereIn
- }
- if(!empty($request->ethnicity)){
- $query->whereIn('modified_dppr2018.Bangsa_updated',$ethnicity);
- }
- if(!empty($request->area)){
- $query->whereIn('modified_dppr2018.Taman_area',$area);
- }
- if(!empty($request->state)){
- $query->whereIn('modified_dppr2018.Negeri',$state);
- }
- if(!empty($request->namaDUN)){
- $query->whereIn('modified_dppr2018.namaDUN',$namaDUN);
- }
- if(!empty($request->income)){
- $query->whereIn('modified_dppr2018_algorithm.income_latest',$income);
- }
- if(!empty($request->education)){
- $query->whereIn('modified_dppr2018_algorithm.Education',$education);
- }
- if(!empty($request->digitalInclination)){
- $query->whereIn('modified_dppr2018_algorithm.digital_inclination',$digitalInclination);
- }
- if(!empty($request->employment)){
- $query->whereIn('modified_dppr2018_algorithm.Employment',$employment);
- }
- if(!empty($request->carOwnership)){
- $query->where('modified_dppr2018_algorithm.prob_owncar','>=',$carOwnership);
- }
- $records_per_page = 100;
- $data = $query->select('modified_dppr2018.id','modified_dppr2018.First_name', 'modified_dppr2018.Last_name',
- 'modified_dppr2018.Umur', 'modified_dppr2018.Phonenum', 'modified_dppr2018.TarikhLahir','modified_dppr2018.Negeri',
- 'modified_dppr2018.Country', 'modified_dppr2018.postcode', 'modified_dppr2018.Ct', 'modified_dppr2018.Jantina')->get();
- return datatables()->of($data)->make(true);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement