Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Get a random domain
- $domain = $this->domainModel->where('status', 'true')->orderBy(DB::raw('RAND()'))->take(1)->first();
- $drivers = $this->driverModel->where('domain_id', $domain->id)
- ->lists('from_category')
- ->all();
- $categoryCar = $this->carModel->where('status', 1)
- ->where('source', $domain->sources)
- ->groupBy('category')
- ->lists('category')
- ->intersect($drivers)
- ->random();
- $driverCategory = $this->driverModel->where('domain_id', $domain->id)
- ->where('from_category', $categoryCar)
- ->first();
- // Get the cars with images an video
- $brands = $this->categoryModel->where('domain_id', $domain->id)
- ->where('parent', $driverCategory->to_category)
- ->lists('name')
- ->all();
- $car = $this->carModel->where('status', 1)
- ->where('source', $domain->sources)
- ->where('category', $driverCategory->from_category);
- if ($brands) {
- $car = $car->whereIn('brand', $brands);
- }
- $car = $car->orderBy(DB::raw('RAND()'))->take(1)->first();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement