Commit 79d849de authored by King Alex's avatar King Alex

Model Search pour faciliter et unifier les recherches

parent c2b760c8
class Search extends Eloquent {
protected $recipes;
function __construct($search){
// TODO create repository
return null;
$searchIngredients = Ingredient::where('name', 'LIKE', '%'.$search.'%')->get();
$searchCategory = Category::where('display_name', 'LIKE', '%'.$search.'%')->first();
$searchRecipes = Recipe::where('title', 'LIKE', '%'.$search.'%')->orwhere('description', 'LIKE', '%'.$search.'%')->get();
// find all recipes that share an id with the search ingredients
foreach($searchIngredients as $ingredient){
$this->recipes[] = $ingredient->recipes()->first() ;
foreach($searchRecipes as $recipe){
foreach ($recipeList as $recipe) {
$this->recipes[] = $recipe;
function get(){
return $this->recipes;
// TODO remove duplicates
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment