protected function food() { if (!$this->session->status()) { return $this->_response("Authentication Required", 401); } $food = new Food(); if ($this->method == 'GET') { if ($this->id) { return $food->getById($this->id); } return $food->getList(); } else { if ($this->method == 'POST') { if ($this->data) { return $food->create($this->data); } } else { if ($this->method == 'DELETE') { if ($this->id) { return $food->deleteById($this->id); } } } } return ""; }
public function putIn(Food $content) { if (in_array($content->getType(), $this->forbiddenFood)) { throw new \ForbiddenFoodTypeException($content->getType()); } $this->content = $content; }
private function wrapComponent(IComponent $component) { $component = new ProgramLang($component); $component->setFeature($this->progLange); $component = new Hardware($component); $component->setFeature($this->hardware); $component = new Food($component); $component->setFeature($this->food); return $component; }
public static function getFoodById($id) { self::$db = Database::getDB(); $query = "select * from food where Food_id='{$id}'"; $result = self::$db->query($query); $item = $result->fetch(); $food = new Food($item["Food_Catagory"], $item["Food_Price"], $item["Food_Instock"], $item["Food_description"], $item["Food_mark"], $item["Food_Name"], $item["Food_Image"], $item["Discount_price"], $item["Viewed_times"], $item["Sales_volume"]); $food->setId($item["Food_id"]); return $food; }
private function wrapComponent(IComponent $component) { $component = new ProgramLang($component); $component->setFeature("php"); $component = new Hardware($component); $component->setFeature("lin"); $component = new Food($component); $component->setFeature("veg"); return $component; }
public static function getfood($food_id) { global $db; $query = "SELECT * FROM foods WHERE foodID = {$food_id}"; $result = $db->query($query); $row = $result->fetch(); $category = CategoryRepository::getCategory($row['categoryID']); $food = new Food($row['calories'], $row['foodTitle'], $row['foodPrice'], $category); $food->setId($row['foodID']); return $food; }
public function getList() { $food = new Food(); $userId = $_SESSION["userId"]; $result = SQL::query("SELECT * FROM calories WHERE user_id = " . $userId . ";"); $response = array(); for ($i = 0; $i < $result->num_rows; $i++) { $line = SQL::fetchAssoc($result); $foodData = $food->getById($line["food_id"]); $line["food_data"] = $foodData; array_push($response, $line); } return $response; }
public function run() { Food::truncate(); Food::create(['name' => 'Oats, Rolled', 'protein' => '0.11', 'carbohydrate' => '0.604', 'fat' => '0.081']); Food::create(['name' => 'Soy Milk', 'protein' => '0.033', 'carbohydrate' => '0.06', 'fat' => '0.018']); Food::create(['name' => 'Banana', 'protein' => '0.011', 'carbohydrate' => '0.23', 'fat' => '0.003']); }
public function add_food_get($menu_id) { $menu_name = Menu::where("menu_id", $menu_id)->first(); $this->_data['foods'] = Food::paginate(10); $this->_data['menus'] = DB::table("menus")->join("menu_foods", "menus.menu_id", "=", "menu_foods.menu_id")->join("foods", "menu_foods.food_id", "=", "foods.food_id")->where("menus.menu_id", $menu_id)->orderBy("menu_foods.created_at", "desc")->get(); return View::make("admin.content.menu.add_food", $this->_data)->with("titlePage", "Add Food In Menu")->with("titleTable", "Thêm món ăn vào thực đơn: <strong>" . $menu_name->menu_name . "</strong>")->with("menu_id", $menu_id); }
/** * Finds the User model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @param integer $create_date * @return GwTransactionLog the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Food::findOne(['id' => $id])) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function deleteFood($id) { $food = Food::find($id); if ($food->delete()) { return Redirect::route('userHome')->with('success', 'User deleted successfuly'); } else { return Redirect::route('userHome')->with('fail', 'Error while deleting food'); } }
/** * Check name is exist in food table * return null if not exist * @param $name name Vietnamese * @return Food */ public function isAvaiableInFoodTable($name) { $slug = Utils::normalizeSlug($name); $sql = "select * from monan where slug = '" . $slug . "' limit 1"; $query = mysql_query($sql); if (mysql_num_rows($query) > 0) { return Food::create(mysql_fetch_array($query)); } }
public function test() { $this->load()->model('Food'); $food = new Food(); echo '<pre>'; //print_r( $food->getById(14) ); //print_r( $food->getById(14, array('limit'=>1)) ); //print_r( $food->limit(10) ); //print_r( $food->limit(10,'id,name') ); //print_r( $food->limit(10,'name','id') ); //print_r( $food->limit(10,'name,id','location') ); //print_r( Food::_limit(10) ); //print_r( $food->getOne() ); //print_r( Food::_getOne() ); //$food->location = 'Asia'; //$food->food_type_id = 10; print_r($food->count()); print_r(Food::_count()); print_r(Food::_count($food)); //Doo::cache('php')->set('foodtotal', Food::_count($food)); //echo '<h1>'. Doo::cache('php')->get('foodtotal') .'</h1>'; print_r(Food::getById__first(6)); //$food->id = 14; //print_r( $food->getOne() ); // print_r( $food->find() ); //print_r( Food::_find($food) ); //print_r( $food->getById_location__first(6, 'Malaysia') ); //print_r( $food->getById_location(6, 'Malaysia', array('limit'=>1)) ); //print_r( $food->relateFoodType($food, array('limit'=>'first')) ); //print_r( $food->relateFoodType($food) ); //print_r( $food->relateFoodType__first($food) ); //print_r( Food::getById__location__first(6, 'Malaysia') ); //print_r( Food::getById__location(6, 'Malaysia') ); //print_r( Food::getById__first(6) ); //print_r( Food::getByLocation('Malaysia') ); //print_r( Food::relateFoodType__first($food) ); //print_r( Food::relateFoodType() ); //print_r( Food::relateFoodType_first() ); //print_r( Food::_relate('', 'FoodType') ); // //$f = new Food; //print_r( $f->relate('FoodType') ); //print_r( $f->relate('FoodType', array('limit'=>'first')) ); # if update/delete/insert cache auto purged on the Model. //$food->id = 6; //$food->name = 'Wan Tan Mee'; //$food->update(); //print_r($food->find()); //$food->purgeCache(); #to delete cache manually //Food::_purgeCache(); #to delete cache manually # If no SQL is displayed, it means that the data are read from cache. # And of course your Model have to extend DooSmartModel print_r(Doo::db()->showSQL()); }
public static function calculate($id) { if ($id == 0) { return array(); } $food = Food::getFood($id); $returnArray = array(); // Search food components table for input food $foodComponents = FoodComponent::getComponentsWithChild($id); foreach ($foodComponents as $foodComponent) { $parentFood = Food::getFood($foodComponent["foodId"]); $returnArray[] = array("foodId" => $parentFood["id"], "foodName" => $parentFood["name"], "componentId" => $food["id"], "componentName" => $food["name"], "quantity" => $foodComponent["quantity"], "unitOfMeasure" => $food["unitOfMeasure"]); } return $returnArray; }
public function edit_post($id) { $valid = Validator::make(Input::all(), Food::rule_edit_food($id), Food::$food_langs); if ($valid->passes()) { $data = Input::all(); $img = $data['food_image']; $isUpload = $img->move("uploads/food/"); if ($isUpload) { $data = array("food_name" => Input::get("food_name"), "food_price" => Input::get("food_price"), "food_description" => Input::get("food_description"), "food_image" => $img->getClientOriginalName(), "food_created_at" => date("Y-m-d")); DB::table("foods")->where("food_id", $id)->update($data); return Redirect::route("manage_food")->with("flash_success", "Chúc mừng bạn đã sửa món ăn thành công"); } return Redirect::route("manage_food")->with("flash_error", "Không thể upload ảnh"); } return Redirect::route("manage_food_edit_get", $id)->withInput()->with("flash_error", $valid->errors()->first()); }
public static function addFood($id, &$shoppingArray, $quantity = 0) { if ($id == 0) { return array(); } // Prepare needed data $food = Food::getFood($id); $foodComponents = FoodComponent::getComponents($id); if (sizeof($foodComponents) == 0) { // Default to serving size in this case if ($quantity == 0) { $quantity = $food["quantity"]; } // No components, just add entry for self self::addShopping($shoppingArray, $id, $food, $quantity); } else { // Default to recipe quantity in this case if ($quantity == 0) { $quantity = $food["recipeQuantity"]; } if ($quantity == 0) { $quantity = $food["quantity"]; } // Return shopping for each component foreach ($foodComponents as $foodComponent) { // Determine component quantity needed if ($food["recipeQuantity"] == 0) { $food["recipeQuantity"] = $food["quantity"]; } if ($food["recipeQuantity"] == 0) { $food["recipeQuantity"] = 1; } $componentQuantity = $foodComponent["quantity"] * $quantity / $food["recipeQuantity"]; self::addFood($foodComponent["componentId"], $shoppingArray, $componentQuantity); } } }
public function __construct($meta = 0, $count = 1) { parent::__construct(self::BEETROOT_SOUP, 0, $count, "Beetroot Soup"); }
public function __construct($meta = 0, $count = 1) { parent::__construct(self::BREAD, $meta, $count, "Bread"); }
public function __construct($meta = 0, $count = 1) { parent::__construct(self::BAKED_POTATO, $meta, $count, "Baked Potato"); }
public function __construct($meta = 0, $count = 1) { parent::__construct(self::GOLDEN_CARROT, 0, $count, "Golden Carrot"); }
public function __construct($meta = 0, $count = 1) { parent::__construct(self::APPLE, 0, $count, "Apple"); }
public function testFoodIsComposedByEightGroupsOfNutrients() { Food::box(['carbohydrates' => 42, 'proteins' => 42, 'fats' => 42, 'minerals' => 42, 'vitamins' => 42, 'phytochemicals' => 42, 'fibers' => 42]); }
public function __construct($meta = 0, $count = 1) { parent::__construct(self::MELON, $meta, $count, "Melon"); }
public function __construct($meta = 0, $count = 1) { parent::__construct(self::STEAK, $meta, $count, "Steak"); }
public function __construct($meta = 0, $count = 1) { parent::__construct(self::MUSHROOM_STEW, 0, $count, "Mushroom Stew"); }
public function __construct($meta = 0, $count = 1) { parent::__construct(self::COOKED_CHICKEN, $meta, $count, "Cooked Chicken"); }
<?php require 'classes/Food.php'; // get all food items route $app->get('/food/', function () use($session) { // if($session->isValidRequest() == 0){ // $session->goodnight(); // } try { $return = array(); $return['success'] = true; $return['data'] = Food::getFood(); $return['time'] = time(); //$return['id'] = $_SESSION['user_id']; $return['sid'] = session_id(); echo json_encode($return); } catch (Exception $e) { echo json_encode($e->getMessage()); } });
public function __construct($meta = 0, $count = 1) { parent::__construct(self::RAW_BEEF, $meta, $count, "Raw Beef"); }
public function __construct($meta = 0, $count = 1) { parent::__construct(self::RAW_PORKCHOP, $meta, $count, "Raw Porkchop"); }
$errors = Food::Delete($_REQUEST['id']); if ($errors) { $model = Food::Get($_REQUEST['id']); $view = "food/delete.php"; } else { header("Location: ?sub_action={$sub_action}&id={$_REQUEST['id']}"); die; } break; case 'search_GET': $model = Food::Search($_REQUEST['q']); $view = 'food/index.php'; break; case 'index_GET': default: $model = Food::Get(); $view = 'food/index.php'; break; } switch ($format) { case 'json': echo json_encode($model); break; case 'plain': include __DIR__ . "/../Views/{$view}"; break; case 'web': default: include __DIR__ . "/../Views/shared/_Template.php"; break; }