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']); } }