platformContentRepository = $platformContentRepository; } //平台内容列表 public function index(Request $request) { $platformContent = $this->platformContentRepository->index($request->all()); $fractal = new Manager(); $resource = new Collection($platformContent, new PlatformContentTransformer()); $resource->setPaginator(new IlluminatePaginatorAdapter($platformContent)); $data = $fractal->createData($resource)->toArray(); $data['extra'] = [ 'filters' => [ 'id', ], 'columns' => [ 'id', 'title', 'content', 'updated_at' ] ]; return $data; } //新增平台内容 public function create(Request $request) { $validator = Validator::make($request->all(), [ 'title' => 'required|string', 'content' => 'required|string', ]); if ($validator->fails()) { return $this->response->error($validator->errors()->first(), 500); } return $this->platformContentRepository->create($request->all()); } //修改平台内容 public function edit(Request $request) { $validator = Validator::make($request->all(), [ 'id' => 'required|exists:platform_content', 'content' => 'required', ]); if ($validator->fails()) { return $this->response->error($validator->errors()->first(), 500); } return $this->platformContentRepository->edit($request->all()); } }