Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0
Solution

This is how I ended up solving this issue:

  $shops = Shop::with('services');

  foreach ($service as $key => $s) {
      $shops->whereHas('services', function($q) use ($s){
          $q->where('id', $s);
      })->orderBy('name', 'asc')
      ->paginate($resultsPerPage);;
  }
  $shops = $shops->orderBy('name', 'asc')->paginate($resultsPerPage);
Last updated 8 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

iign iign Joined 23 Mar 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.