1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- namespace App\Http\Controllers\V2;
- use App\Http\Controllers\BaseController;
- use App\Repositories\PlatformContentRepository;
- use App\Transformers\PlatformContentTransformer;
- use Illuminate\Http\Request;
- use League\Fractal\Resource\Collection;
- use League\Fractal\Manager;
- use League\Fractal\Pagination\IlluminatePaginatorAdapter;
- /**
- * Created by PhpStorm.
- * User: durong
- * Date: 2019/6/17
- * Time: 下午6:42
- */
- class PlatformContentController extends BaseController
- {
- public function __construct(PlatformContentRepository $platformContentRepository)
- {
- $this->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();
- return $this->jsonSuccess($data);
- }
- }
|