Advertisement
Guest User

Untitled

a guest
Nov 26th, 2015
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.22 KB | None | 0 0
  1. <?php
  2.  
  3.  // Get a random domain
  4.         $domain = $this->domainModel->where('status', 'true')->orderBy(DB::raw('RAND()'))->take(1)->first();
  5.  
  6.         $drivers = $this->driverModel->where('domain_id', $domain->id)
  7.             ->lists('from_category')
  8.             ->all();
  9.  
  10.         $categoryCar = $this->carModel->where('status', 1)
  11.             ->where('source', $domain->sources)
  12.             ->groupBy('category')
  13.             ->lists('category')
  14.             ->intersect($drivers)
  15.             ->random();
  16.  
  17.         $driverCategory = $this->driverModel->where('domain_id', $domain->id)
  18.             ->where('from_category', $categoryCar)
  19.             ->first();
  20.  
  21.         // Get the cars with images an video
  22.         $brands = $this->categoryModel->where('domain_id', $domain->id)
  23.             ->where('parent', $driverCategory->to_category)
  24.             ->lists('name')
  25.             ->all();
  26.  
  27.         $car = $this->carModel->where('status', 1)
  28.             ->where('source', $domain->sources)
  29.             ->where('category', $driverCategory->from_category);
  30.        
  31.         if ($brands) {
  32.             $car = $car->whereIn('brand', $brands);
  33.         }
  34.        
  35.  
  36.         $car = $car->orderBy(DB::raw('RAND()'))->take(1)->first();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement