merge(['pid'=>0]); $request->merge(['is_show'=>1]); $category = new VideoCategory(); if ($request->has('id')){ $category = VideoCategory::find($request->input('id')); $result = $category->fill($request->all()); $res = $result->save(); }else{ $result = $category->fill($request->all()); $res = $result->save(); } return $res ? $this->success($result) : $this->failed('保存失败'); } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { // } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { // } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // VideoCategory::where('id', $id)->firstOrFail(); $result = Video::where('first_id', $id)->where('deleted_at', null)->where('platform', 'psy_center')->first(); if($result) { return $this->failed('该分类下有视频,请先删除视频'); } $res = VideoCategory::destroy($id); if($res) { return $this->success(''); }else { return $this->failed('删除失败'); } } }