public function edit_get($id) { $this->_data['data'] = Food::where("food_id", $id)->first(); return View::make("admin.content.food.edit", $this->_data)->with("titlePage", "Edit Food")->with("titleTable", "Sửa món ăn tại nhà hàng"); }
// sayfalı son yemekler $this->get('/all/{page:[0-9]+}', function ($request, $response, $args) { $food = Food::select('food_id', 'name', 'description')->where('deleted', 0)->take(6)->offset($args['page'] * 6)->orderBy('food_id', 'DESC')->get(); if ($food) { return $response->write(json_encode($food) . ' '); } return $response->write('{"msg": "ERR"}'); })->setName('foods'); // sayfalı son yemekler $this->get('/popular/{page:[0-9]+}', function ($request, $response, $args) { $food = Food::take(6)->offset($args['page'] * 6)->orderBy('displayed', 'DESC')->get(); return $response->write(json_encode($food) . ' '); })->setName('popular_foods'); // id'den yemek $this->get('/{id:[0-9]+}', function ($request, $response, $args) { $food = Food::where('food_id', $args['id'])->where('deleted', 0)->get()->first(); $food->displayed = $food->displayed + 1; $food->save(); if ($food) { $food->user = $food->profile(); return $response->write(json_encode($food) . ' '); } return $response->write('{"msg": "ERR"}'); })->setName('food_detail'); // yemeğe yapılan yorumlar $this->get('/{id:[0-9]+}/comments/{page:[0-9]+}', function ($request, $response, $args) { $comments = Comment::where('food_id', $args['id'])->where('deleted', 0)->take(10)->offset($args['page'] * 10)->orderBy('comment_id', 'DESC')->get(); return $response->write(json_encode($comments) . ' '); })->setName('food_comments'); // yemek ekle $this->post('', function ($request, $response, $args) {
/** * * @param $typing * @return mixed */ private function foods($typing) { $foods = Food::where('user_id', Auth::user()->id)->where('name', 'LIKE', $typing)->with('defaultUnit')->with('units')->get(); return $foods; }