|
@@ -1,8 +1,11 @@
|
|
<?php
|
|
<?php
|
|
namespace App\Http\Controllers;
|
|
namespace App\Http\Controllers;
|
|
-use App\Models\ConfigStoreType;
|
|
|
|
|
|
+use App\Repositories\ConfigStoreTypeRepository;
|
|
use App\Transformers\ConfigStoreTypeTransformer;
|
|
use App\Transformers\ConfigStoreTypeTransformer;
|
|
-
|
|
|
|
|
|
+use Illuminate\Http\Request;
|
|
|
|
+use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
|
|
|
+use League\Fractal\Resource\Collection;
|
|
|
|
+use League\Fractal\Manager;
|
|
/**
|
|
/**
|
|
* Created by PhpStorm.
|
|
* Created by PhpStorm.
|
|
* User: qinyaer
|
|
* User: qinyaer
|
|
@@ -12,42 +15,31 @@ use App\Transformers\ConfigStoreTypeTransformer;
|
|
|
|
|
|
class StoreTypeController extends BaseController
|
|
class StoreTypeController extends BaseController
|
|
{
|
|
{
|
|
- /**
|
|
|
|
- * @api {get} /storeType/index 储存方式列表
|
|
|
|
- * @apiVersion 0.1
|
|
|
|
- * @apiName StoreType index
|
|
|
|
- * @apiGroup StoreType
|
|
|
|
- * @apiPermission none
|
|
|
|
- * @apiSuccessExample 成功响应:
|
|
|
|
|
|
|
|
|
|
+ public function __construct(ConfigStoreTypeRepository $configStoreTypeRepository)
|
|
{
|
|
{
|
|
- "data": [],
|
|
|
|
- "extra": {
|
|
|
|
- "filters": [
|
|
|
|
- "筛选字段1",
|
|
|
|
- "筛选字段2"
|
|
|
|
- ],
|
|
|
|
- "columns": [
|
|
|
|
- "id",
|
|
|
|
- "name"
|
|
|
|
- ]
|
|
|
|
- },
|
|
|
|
- "meta": {
|
|
|
|
- "pagination": {
|
|
|
|
- "total": 2,
|
|
|
|
- "count": 2,
|
|
|
|
- "per_page": 15,
|
|
|
|
- "current_page": 1,
|
|
|
|
- "total_pages": 1,
|
|
|
|
- "links": []
|
|
|
|
- }
|
|
|
|
|
|
+ $this->configStoreTypeRepository = $configStoreTypeRepository;
|
|
}
|
|
}
|
|
- */
|
|
|
|
- public function index()
|
|
|
|
|
|
+
|
|
|
|
+ //分类列表
|
|
|
|
+ public function index(Request $request)
|
|
{
|
|
{
|
|
- $ConfigStoreType = ConfigStoreType::orderBy('id', 'desc')
|
|
|
|
- ->paginate();
|
|
|
|
|
|
|
|
- return $this->response->paginator($ConfigStoreType, new ConfigStoreTypeTransformer());
|
|
|
|
|
|
+ $configStoreType = $this->configStoreTypeRepository->index($request->all());
|
|
|
|
+ $fractal = new Manager();
|
|
|
|
+ $resource = new Collection($configStoreType, new ConfigStoreTypeTransformer());
|
|
|
|
+ $resource->setPaginator(new IlluminatePaginatorAdapter($configStoreType));
|
|
|
|
+ $data = $fractal->createData($resource)->toArray();
|
|
|
|
+ $data['extra'] = [
|
|
|
|
+ 'filters' => [
|
|
|
|
+ 'id'
|
|
|
|
+ ],
|
|
|
|
+ 'columns' => [
|
|
|
|
+ 'id',
|
|
|
|
+ 'name',
|
|
|
|
+ ]
|
|
|
|
+ ];
|
|
|
|
+ return $data;
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|