Skip to content

Instantly share code, notes, and snippets.

@joelbrennan0
Last active January 13, 2016 19:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joelbrennan0/5bf743e4d8fe1617779a to your computer and use it in GitHub Desktop.
Save joelbrennan0/5bf743e4d8fe1617779a to your computer and use it in GitHub Desktop.
Laravel Search ( model ) by Category
public function getCategory($category) {
$customers = Customer::whereHas('categories', function($query) use
($category) {
$query->where('name', '=', $category);
})->get();
return view('customers.index', compact('customers'));
}
//http://laravel.io/forum/02-25-2014-eager-loading-with-constrains-load-post-based-on-category-name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment