public function deletemenu() { if (Session::get('logininfo')->level == 3) { return view('admin.error'); } if (Input::get("root") === "0") { $menu = menu::where('root', Input::get('id'))->get(); if (count($menu) > 0) { if (Input::exists('json')) { return json_encode(array('result' => -1, 'message' => 'Menu "' . Input::get('title') . '" đã có menu con. Không thể xóa')); } } } if (Input::get("url2") == "") { $product = product::where('menuID', Input::get('id'))->get(); if (count($product) > 0) { if (Input::exists('json')) { return json_encode(array('result' => -1, 'message' => 'Menu "' . Input::get('title') . '" đã có sản phẩm. Không thể xóa')); } } } $menu = menu::find(Input::get('id')); if ($menu->delete()) { if (Input::exists('json')) { return json_encode(array('result' => 1)); } } else { if (Input::exists('json')) { return json_encode(array('result' => -1, 'message' => 'Có lỗi. Xóa thất bại')); } } }