Commit 878ae6ba authored by King Alex's avatar King Alex

Ajout fonctionalite de barre de recherche

parent 270ac7c9
......@@ -17,7 +17,7 @@ class RecipeController extends BaseController {
// Returns
public function get($id){
$recipe_display = new RecipeDisplay($id); // TODO check the id here.
$recipe_display = new RecipeDisplay($id); // TODO check the id here if it exists.
if(is_null($recipe_display)){
alert('Error: Recipe not found');
return $this->list();
......@@ -31,55 +31,22 @@ class RecipeController extends BaseController {
return View::make('templates.recipe.create')->with('categories',$catList);
}
// TODO pass list of recipes containing the search term.
public function search(){
// example:
/*
Product::with('owner')->where(function($query) use ($searchText)
{
$query->where('product_name', 'LIKE', '%' . $searchText . '%');
$columns = ['product_code', 'place_location', 'remark'];
foreach ($columns as $column ) {
$query->orWhere($column, 'LIKE', '%' . $searchText . '%');
}
$query->orWhereHas('owner', function($q) use ($searchText) {
$q->where(function($q) use ($searchText) {
$q->where('name', 'LIKE', '%' . $searchText . '%');
$q->orWhere('company_name', 'LIKE', '%' . $searchText . '%');
});
});
});
*/
$searchText = Input::get('q');
var_dump($searchText);
/*
$results = Profile::where('location_id', '=', $locationId)
->whereHas('services', function($query) use ($serviceId){
$query->where('services.id', '=', $serviceId);
})->get();
*/
$searchIngredients = Ingredient::where('name', 'LIKE', '%'.$searchText.'%')->get();
$searchCategory =Category::where('display_name', 'LIKE', '%'.$searchText.'%')->get();
$searchRecipes = Recipe::where('title', 'LIKE', '%'.$searchText.'%')->orwhere('description', 'LIKE', '%'.$searchText.'%')->get();
var_dump($ingredients);
die();
$results = Recipe::where('location_id', '=', $locationId)
->whereHas('services', function($query) use ($serviceId){
$query->where('services.id', '=', $serviceId);
})->get();
var_dump($recipeList);
die();
foreach ($recipeList as $recipe) {
var_dump($recipe['title']);
$search = new Search($searchText);
$recipeList = $search->get();
$list = [];
if(is_null($recipeList)){
return $this->list();
}
foreach($recipeList as $recipe){
$recipe_display = new RecipeDisplay($recipe->id);
array_push($list, $recipe_display->get());
}
// TODO Get collection of recipes
return View::make('templates.recipe.list')->with('recipes',$list);
return View::make('templates.recipe.list')->with('recipes',$list);
}
public function doCreate(){
......@@ -130,8 +97,6 @@ class RecipeController extends BaseController {
return $this->list();
}
// TODO -> Add admin panel
// TODO -> CRUD images / recipes / ingredients
}
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