From 9e435ce9589e9e652b4934055a8ad6274124a02b Mon Sep 17 00:00:00 2001 From: weizong song Date: Fri, 21 May 2021 09:55:59 +0800 Subject: [PATCH] up --- .../Manager/TrainingController.php | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/Manager/TrainingController.php b/app/Http/Controllers/Manager/TrainingController.php index aace1b9..02e2ae5 100644 --- a/app/Http/Controllers/Manager/TrainingController.php +++ b/app/Http/Controllers/Manager/TrainingController.php @@ -37,10 +37,19 @@ class TrainingController extends CommonController }); } $page_size = request()->page_size ? (int)request()->page_size : 3; - $data = $data->with(["type" => function ($query) { - $query->select("id", "name"); - }])->select("id", "type_id", "title", "poster", "video as video_stopped", "published_at")->orderBy("published_at","desc")->paginate($page_size); - return response()->json($data->toArray()); + + //todo:配置视频开启用户 + if ($this->manager->username == "liuyu") { + $data = $data->with(["type" => function ($query) { + $query->select("id", "name"); + }])->select("id", "type_id", "title", "poster", "video", "published_at")->orderBy("published_at","desc")->paginate($page_size); + } else { + $data = $data->with(["type" => function ($query) { + $query->select("id", "name"); + }])->select("id", "type_id", "title", "poster", "video as video_stopped", "published_at")->orderBy("published_at","desc")->paginate($page_size); + + } + return response()->json($data->toArray()); } /** @@ -58,9 +67,16 @@ class TrainingController extends CommonController public function getVideo($id) { - $video = Training::with(["type" => function ($query) { - $query->select("id", "name"); - }])->select("id", "type_id", "title", "poster", "video as video_stopped", "published_at")->find($id); + //todo:配置视频开启用户 + if ($this->manager->username == "liuyu") { + $video = Training::with(["type" => function ($query) { + $query->select("id", "name"); + }])->select("id", "type_id", "title", "poster", "video as video", "published_at")->find($id); + } else { + $video = Training::with(["type" => function ($query) { + $query->select("id", "name"); + }])->select("id", "type_id", "title", "poster", "video as video_stopped", "published_at")->find($id); + } return response()->json($video->toArray()); }