SHARE
TWEET

Untitled

a guest Aug 19th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Contact::when($request->client && $request->search, function ($q) use($request) {
  2.     $q->whereHas('companies', function ($q) use ($request) {
  3.         $q->where('is_client', true);
  4.     })->where(function ($q) use ($request) {
  5.         $q->where('first_name', 'like', '%'.$request->search.'%')
  6.         ->orWhere('last_name', 'like', '%'.$request->search.'%')
  7.         ->orWhereHas('companies', function ($q) use ($request) {
  8.             $q->where('name', 'like', '%' . $request->search . '%');
  9.         });
  10.     });
  11. })->when($request->client == null && $request->search, function ($q) use($request) {
  12.     $q->where('first_name', 'like', '%'.$request->search.'%')
  13.         ->orWhere('last_name', 'like', '%'.$request->search.'%')
  14.         ->orWhereHas('companies', function ($q) use ($request) {
  15.             $q->where('name', 'like', '%' . $request->search . '%');
  16.         });
  17. })->when($request->client && $request->search == null, function ($q) use ($request) {
  18.     $q->whereHas('companies', function ($q) use ($request) {
  19.         $q->where('is_client', true);
  20.     });
  21. })
  22.     ->paginate(30)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top