Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. $second = DB::table('vendor_profiles')
  2. ->select('vendor_profiles.id')
  3. ->leftjoin('vendor_franchise', function ($join) {
  4. $join->on('vendor_profiles.id', '=', 'vendor_franchise.vendor_profile_id');
  5. })
  6. ->whereIn('vendor_franchise.franchise', $locations)
  7. ->where('vendor_profiles.status', 1)
  8. ->where('vendor_profiles.approved', 1);
  9.  
  10.  
  11. $first = DB::table('vendor_profiles')
  12. ->select('vendor_profiles.id')
  13. ->leftjoin('vendor_franchise', function ($join) {
  14. $join->on('vendor_profiles.id', '=', 'vendor_franchise.vendor_profile_id');
  15. })
  16. ->whereIn('vendor_profiles.state', $locations)
  17. ->where('vendor_profiles.status', 1)
  18. ->where('vendor_profiles.approved', 1)
  19. ->orderBy('vendor_profiles.updated_at', 'DESC')
  20. ->groupBy('vendor_profiles.id')
  21. ->union($second)
  22. ->pluck('id');
  23.  
  24. return VendorProfiles::with('franchise')
  25. ->with('businessNature')
  26. ->with('promotions')
  27. ->with(['bookmark' => function ($query){
  28. if(Auth::user()){
  29. $query->where('user_id',Auth::user()->id);
  30. }
  31. }])
  32. ->with('reviews')
  33. ->withCount('reviews')
  34. ->whereIn('id', $first)
  35. ->orderBy('updated_at', 'DESC')
  36. ->get();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement