12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <?php
- namespace App\Http\Controllers\Web;
- use App\Http\Controllers\Controller;
- use App\Http\Requests\VideoRequest;
- use App\Models\Video;
- use App\Models\VideoCategory;
- use App\Services\VideoService;
- use Illuminate\Http\Request;
- class VideoController extends Controller
- {
- //
- public function index(Request $request, VideoService $service){
- $category = VideoCategory::select('id', 'name','is_show','rank')->where('is_show', 1)->where('pid', 0)->orderBy('rank','DESC')->get()->toArray();
-
- $condition['keywords'] = $request->input('keywords', '');
- $condition['category_id'] = $request->input('category_id', 0);
- // $condition['platform'] = 'psy_center';
- $condition['type'] = 3;
- $condition['platform'] = 'psy_center';
- $video = $service->getList($condition);
- // var_dump($video);exit;
- // print_r($category);exit;
- return view('psycenter.video', ['categories'=>$category, 'video'=>$video,'condition'=>$condition, 'title'=>'视频']);
- }
- public function store(VideoRequest $request)
- {
-
- $category = new Video();
- $request->merge(['type' => 3]);
- $request->merge(['platform'=>'psy_center']);
- if ($request->has('id')){
- $category = Video::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('保存失败');
- }
- public function show($id)
- {
- $video = Video::where('id', $id)->firstOrFail();
- return $this->success($video);
- }
- public function destroy($id)
- {
-
- Video::where('id', $id)->firstOrFail();
- $res = Video::destroy($id);
- if($res) {
- return $this->success('');
- }else {
- return $this->failed('删除失败');
- }
- }
- public function delete()
- {
- $ids = request()->input('ids');
- $res = Video::whereIn('id', $ids)->delete();
- if($res) {
- return $this->success('');
- }else {
- return $this->failed('删除失败');
- }
- }
- }
|