本文整理汇总了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);
}