12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- namespace App\Http\Controllers\Web;
- use App\Http\Controllers\Controller;
- use App\Http\Requests\CategoryRequest;
- use App\Models\Video;
- use App\Models\VideoCategory;
- use Illuminate\Http\Request;
- class VideoCategoryController extends Controller
- {
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function index()
- {
- //
- }
- /**
- * Store a newly created resource in storage.
- *
- * @param \Illuminate\Http\Request $request
- * @return \Illuminate\Http\Response
- */
- public function store(CategoryRequest $request)
- {
- //
- $request->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('删除失败');
- }
- }
- }
|