private function populateSearchView($text)
 {
     $all_ingredient = array();
     $ingredients_id = array();
     $recipes = array();
     foreach ($text as $t) {
         $string = "%" . trim($t) . "%";
         $db = DB::select("select r.id_recipe,r.title,r.description,r.image, ri.id_ingredient\n                          from recipes r, recipes_ingredients ri\n                          where ri.id_recipe = r.id_recipe and ri.id_ingredient in (select id_ingredient from ingredients where name like ?)", [$string]);
         foreach ($db as $index => $d) {
             $ingredients_id[] = $d->id_ingredient;
             $name_ingredient = Ingredients::where('id_ingredient', '=', $d->id_ingredient)->first()->name;
             $recipes[$d->id_recipe]['recipe'] = $db[$index];
             $recipes[$d->id_recipe]['ingredients'][] = $name_ingredient;
             $all_ingredient[$d->id_ingredient] = $name_ingredient;
         }
     }
     $todos_ingredient = Ingredients::all();
     $ingredients_id = serialize($ingredients_id);
     $freezer = NULL;
     if (Auth::check()) {
         $geladeira = Freezers::where('id_user', '=', Auth::user()->id)->get();
         foreach ($geladeira as $f) {
             $freezer[$f->id_ingredient] = Ingredients::where('id_ingredient', '=', $f->id_ingredient)->first()->name;
         }
     }
     return ['recipes' => $recipes, 'all_ingredient' => $all_ingredient, 'ingredients_id' => $ingredients_id, 'freezer' => $freezer, 'todos_ingredient' => $todos_ingredient];
 }
 private function populateArray()
 {
     $ingredients = array();
     if (Auth::check()) {
         $freezer = Freezers::where('id_user', '=', Auth::user()->id)->get();
         foreach ($freezer as $f) {
             $ingredients[$f->id_ingredient] = Ingredients::where('id_ingredient', '=', $f->id_ingredient)->first()->name;
         }
     }
     $all_ingredient = Ingredients::all();
     $array['ingredient'] = $ingredients;
     $array['all_ingredient'] = $all_ingredient;
     return $array;
 }