本文整理匯總了PHP中Food::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP Food::create方法的具體用法?PHP Food::create怎麽用?PHP Food::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Food
的用法示例。
在下文中一共展示了Food::create方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: food
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 "";
}
示例2: run
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']);
}
示例3: isAvaiableInFoodTable
/**
* 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));
}
}
示例4: add_post
public function add_post()
{
$valid = Validator::make(Input::all(), Food::$rule_add_food, Food::$food_langs);
if ($valid->passes()) {
$data = Input::all();
$img = $data['food_image'];
$isUpload = $img->move("uploads/food/images/", $img->getClientOriginalName());
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"));
Food::create($data);
return Redirect::route("manage_food_add_get")->with("flash_success", "Chúc mừng bạn đã thêm món ăn thành công");
}
return Redirect::route("manage_food_add_get")->with("flash_success", "Không thể upload ảnh");
}
return Redirect::route("manage_food_add_get")->withInput()->with("flash_error", $valid->errors()->first());
}
示例5: create
public function create()
{
return Food::create($this->params);
}