public function delete()
 {
     $product = product::where('tab_categoryID', Input::get('id'))->get();
     if (count($product) > 0) {
         if (Input::exists('json')) {
             return json_encode(array('result' => -1, 'message' => 'Tab "' . Input::get('title') . '" đã có sản phẩm. Không thể xóa'));
         }
         return Redirect::to('admin/category')->with(['message' => 'Tab "' . Input::get('title') . '" đã có sản phẩm. Không thể xóa']);
     }
     $tab_category = tab_category::find(Input::get('id'));
     if ($tab_category->delete()) {
         if (Input::exists('json')) {
             return json_encode(array('result' => 1));
         }
         return Redirect::to('admin/tab')->with(['message' => 'Xóa thành công tab "' . Input::get('title') . '"']);
     } else {
         if (Input::exists('json')) {
             return json_encode(array('result' => -1, 'message' => 'Có lỗi. Xóa thất bại'));
         }
         return Redirect::to('admin/tab')->with(['message' => 'Tab "' . Input::get('title') . '" đã có nội dung hoặc sản phẩm. Không thể xóa']);
     }
 }
 public function edit()
 {
     if (!Input::exists('id')) {
         return Redirect::to('admin/product')->with(['message' => 'Vui lòng chọn 1 sản phẩm để sửa.']);
     }
     $data = array();
     $data['data'] = product::where('id', Input::get('id'))->first();
     if ($data['data'] == null) {
         return Redirect::to('admin/product')->with(['message' => 'Sản phẩm không tồn tại.']);
     }
     $data['datamenu'] = menu::select('id', 'name', 'root')->where('url', '')->get();
     $data['datacategory'] = category::select('id', 'name')->get();
     $data['datatabcategory'] = tab_category::select('id', 'name')->get();
     $data['detail'] = detailproduct::where('productID', Input::get('id'))->first();
     return View::make("admin.product.edit", $data);
 }
 public static function getTab_category()
 {
     $tab_category = new tab_category();
     return $tab_category->orderBy('id', 'desc')->get();
 }