isAjax()) { $videoCateService = new VideoCateService(); $res = $videoCateService->getList(request()->all()); return sparkSuccess($res); } return view('train/learn/video_cate/index'); } /** * 添加 */ public function store() { if (request()->isAjaxPost()) { $param = request()->post(); $videoCateService = new VideoCateService(); $res = $videoCateService->addVideoCate($param); return sparkSuccess($res); } return view('train/learn/video_cate/add'); } /** * 编辑 */ public function update() { if (request()->isAjaxPost()) { $param = request()->post(); $videoCateService = new VideoCateService(); $res = $videoCateService->editVideo($param); return sparkSuccess($res); } $id = request()->input('id'); $videoCateModel = new VideoCate(); View::assign([ 'info' => $videoCateModel->getInfoById($id) ]); return view('train/learn/video_cate/edit'); } /** * 删除 */ public function destroy() { $id = request()->input('id'); $videoModel = new Video(); $has = $videoModel->getInfoByWhere(['cate_id' => $id]); if (!empty($has)) { throw new ApiException('该分类下有文章不可删除', -1); } $videoCateModel = new VideoCate(); $videoCateModel->delById($id); return sparkSuccess(dataReturn(0, '删除成功')); } }