|
@@ -12,6 +12,7 @@ namespace App\Http\Controllers\V2;
|
|
|
use App\Http\Controllers\Controller;
|
|
|
use App\Repositories\V2\VideoGroupRepository;
|
|
|
use App\Transformers\DetailVideoGroupTansformer;
|
|
|
+use App\Transformers\VideoGroupInfoTransformer;
|
|
|
use App\Transformers\VideoGroupTransformer;
|
|
|
use Illuminate\Http\Request;
|
|
|
use Illuminate\Support\Facades\Validator;
|
|
@@ -49,7 +50,7 @@ class VideoGroupController extends Controller {
|
|
|
public function create(Request $request){
|
|
|
$data = $request->only('name');
|
|
|
$validator = Validator::make($data, [
|
|
|
- 'name' => 'required|string|max:12',
|
|
|
+ 'name' => 'required|string|max:20',
|
|
|
]);
|
|
|
if ($validator->fails()) {
|
|
|
return $this->response->error($validator->errors()->first(), 500);
|
|
@@ -58,7 +59,7 @@ class VideoGroupController extends Controller {
|
|
|
}
|
|
|
//详情
|
|
|
public function view(Request $request){
|
|
|
- $data = $request->only('id');
|
|
|
+ $data = $request->all();
|
|
|
$validator = Validator::make($data, [
|
|
|
'id' => 'required|integer|max:12',
|
|
|
]);
|
|
@@ -66,16 +67,35 @@ class VideoGroupController extends Controller {
|
|
|
return $this->response->error($validator->errors()->first(), 500);
|
|
|
}
|
|
|
$info = $this->videoGroupRepository->view($data);
|
|
|
- return $this->response->item($info, new DetailVideoGroupTansformer());
|
|
|
+ $videoInfo = $this->videoGroupRepository->VideoInfoIndex($data);
|
|
|
+ $fractal = new Manager();
|
|
|
+ $resource = new Collection($videoInfo, new VideoGroupInfoTransformer());
|
|
|
+ $resource->setPaginator(new IlluminatePaginatorAdapter($videoInfo));
|
|
|
+ $data = $fractal->createData($resource)->toArray();
|
|
|
+ $data['extra'] = [
|
|
|
+ 'filters' => [
|
|
|
+ 'name',
|
|
|
+ ],
|
|
|
+ 'columns' => [
|
|
|
+ 'id',
|
|
|
+ 'name',
|
|
|
+ 'video_count',
|
|
|
+ 'created_at',
|
|
|
+ ],
|
|
|
+ 'name'=>$info['name'],
|
|
|
+ 'id'=>$info['id'],
|
|
|
+ ];
|
|
|
+ return $data;
|
|
|
}
|
|
|
//设置排序
|
|
|
public function edit(Request $request){
|
|
|
- $data = $request->only('name','name','info');
|
|
|
+ $data = $request->only('id','name','video_info');
|
|
|
$validator = Validator::make($data, [
|
|
|
'id' => 'required|integer|max:12',
|
|
|
'name' => 'required|string|max:12',
|
|
|
- 'info' => 'string'
|
|
|
+ 'video_info' => 'string'
|
|
|
]);
|
|
|
+
|
|
|
if ($validator->fails()) {
|
|
|
return $this->response->error($validator->errors()->first(), 500);
|
|
|
}
|
|
@@ -93,4 +113,15 @@ class VideoGroupController extends Controller {
|
|
|
}
|
|
|
return $this->videoGroupRepository->addVideoInfo($data);
|
|
|
}
|
|
|
+ //删除内容
|
|
|
+ public function deleteVideoInfo(Request $request){
|
|
|
+ $data = $request->only('id');
|
|
|
+ $validator = Validator::make($data, [
|
|
|
+ 'id' => 'required|integer|max:12',
|
|
|
+ ]);
|
|
|
+ if ($validator->fails()) {
|
|
|
+ return $this->response->error($validator->errors()->first(), 500);
|
|
|
+ }
|
|
|
+ return $this->videoGroupRepository->deleteVideoInfo($data['id']);
|
|
|
+ }
|
|
|
}
|