public function indexByProduct($productSlug) { $product = Product::live()->where('slug', '=', $productSlug)->first(); if (!$product) { \App::abort(404); } $recipes = Recipe::select('fbf_food_recipes.*')->join('fbf_food_product_recipe', 'fbf_food_recipes.id', '=', 'fbf_food_product_recipe.recipe_id')->join('fbf_food_products', 'fbf_food_product_recipe.product_id', '=', 'fbf_food_products.id')->where('fbf_food_products.slug', '=', $productSlug)->live()->orderBy('fbf_food_recipes.name')->paginate(); return \View::make(\Config::get('laravel-food::views.recipes.index'))->with(compact('product', 'recipes')); }
private function getResults($separator) { $where = array(); $bindings = array(); foreach ($this->filters as $key => $value) { $operator = strpos($value, '%') !== false ? 'LIKE' : '='; $where[] = $key . ' ' . $operator . ' :' . $key; $bindings[$key] = $value; } if (!empty($where)) { $sql = 'SELECT * FROM recipe WHERE 1 AND (' . implode(' ' . $separator . ' ', $where) . ')'; $this->results = Recipe::select($sql, $bindings); $this->count = count($this->results); } return $this; }
<?php require_once 'config/config.conf.php'; //$random_recipes = Recipe::getList('*', '', array(), 'RAND()', 3); $random_recipes = Recipe::select('SELECT * FROM recipe ORDER BY RAND() LIMIT 3'); $vars = array('random_recipes' => $random_recipes); Model::displayTemplate('index.tpl', $vars);