Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. $harvesters = DB::table('harvester')
  2. ->select('harvester.id as havId','brand.id as brandId','brand.name as brandName','brand.slug as brandSlug','harvester.slug as havSlug','model_name','harvester.image as havImage','power_Source','cutterbar','epower','hprice','harvester.crop')
  3. ->join('brand','brand.id','=','harvester.brand')
  4. ->where('status',1)
  5. ->get();
  6.  
  7. if($this->request->ajax()){
  8.  
  9. if($this->request->has('brands') && $this->request->has('brands') !== null)
  10. {
  11. $brands = explode(",",$this->request->brands);
  12. $harvesters = $harvesters->whereIn('harvester.brand',$brands);
  13. }
  14.  
  15. if($this->request->has('cuttingwidth') && $this->request->has('cuttingwidth') !== null)
  16. {
  17. $cuttingwidth = explode(",",$this->request->cuttingwidth);
  18.  
  19. if(count($cuttingwidth) == 1)
  20. {
  21. if($cuttingwidth[0] == 'lessthan10')
  22. $harvesters = $harvesters->whereBetween('cutterbar',[1,10]);
  23. elseif($cuttingwidth[0] == 'greternthan10')
  24. $harvesters = $harvesters->whereBetween('cutterbar',[11,20]);
  25. }
  26. elseif(count($cuttingwidth) > 1)
  27. {
  28. $harvesters = $harvesters->whereBetween('cutterbar',[1,20]);
  29. }
  30. }
  31.  
  32. if($this->request->has('power') && $this->request->has('power') !== null)
  33. {
  34. $self = explode(",",$this->request->power);
  35. $harvesters = $harvesters->whereIn('power_Source',$self);
  36.  
  37. }
  38. $harvesters = $harvesters->paginate(10, ['*'], 'page', $page);
  39. return view('pages.harvesterGrid')->with('harvesters',$harvesters);
  40. }
  41.  
  42. else{
  43. return view('layouts.harvesterGrid')->with('harvesters',$harvesters);
  44. }
  45. }
  46.  
  47. <div class="col-md-9 col-sm-12 col-xs-12">
  48. @if(Request::has('brands') || Request::has('cuttingwidth') || Request::has('power'))
  49. {{$harvesters->appends(['brands' => Request()->brands ,'cuttingwidth' =>Request()->cuttingwidth,'power' => Request()->power,])->links()}}
  50. @else
  51. {{$harvesters->links()}}
  52. @endif
  53. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement