Last active
January 13, 2016 19:51
-
-
Save joelbrennan0/5bf743e4d8fe1617779a to your computer and use it in GitHub Desktop.
Laravel Search ( model ) by Category
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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