Skip to content

Instantly share code, notes, and snippets.

@kdes70
Created April 27, 2018 04:43
Show Gist options
  • Save kdes70/80f7de8134e2f44725c90810b8c25fdb to your computer and use it in GitHub Desktop.
Save kdes70/80f7de8134e2f44725c90810b8c25fdb to your computer and use it in GitHub Desktop.
#laravel #whereHas
// result WHERE foreignKey = X AND (first_name = Y OR last_name = Z)
bookings=$bookings->whereHas('client',function($q) use ($client_name){
$q->where( function ($q) use ($client_name) {
$q->where('first_name','LIKE',$client_name)
->orWhere('last_name','LIKE',$client_name);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment