|
@@ -0,0 +1,54 @@
|
|
|
|
+<?php
|
|
|
|
+namespace App\Http\Controllers\Behavior;
|
|
|
|
+/**
|
|
|
|
+ * Created by PhpStorm.
|
|
|
|
+ * User: durong
|
|
|
|
+ * Date: 2019/6/10
|
|
|
|
+ * Time: 上午11:09
|
|
|
|
+ */
|
|
|
|
+use App\Http\Controllers\Controller;
|
|
|
|
+use App\Repositories\BehaviorRepository;
|
|
|
|
+use App\Transformers\Behavior\BehaviorTransformer;
|
|
|
|
+use Illuminate\Http\Request;
|
|
|
|
+use Illuminate\Validation\Rule;
|
|
|
|
+use League\Fractal\Manager;
|
|
|
|
+use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
|
|
|
+use League\Fractal\Resource\Collection;
|
|
|
|
+
|
|
|
|
+class BehaviorController extends Controller
|
|
|
|
+{
|
|
|
|
+ public function __construct(BehaviorRepository $behaviorRepository)
|
|
|
|
+ {
|
|
|
|
+ $this->behaviorRepository = $behaviorRepository;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 行为列表
|
|
|
|
+ */
|
|
|
|
+ public function index(Request $request)
|
|
|
|
+ {
|
|
|
|
+ $behavior_list = $this->behaviorRepository->index($request->all());
|
|
|
|
+ if ($behavior_list){
|
|
|
|
+ return $behavior_list;
|
|
|
|
+ }else{
|
|
|
|
+ return '没有找到对应行为列表';
|
|
|
|
+ }
|
|
|
|
+ $fractal = new Manager();
|
|
|
|
+ $resource = new Collection($behavior_list, new BehaviorTransformer());
|
|
|
|
+ $resource->setPaginator(new IlluminatePaginatorAdapter($behavior_list));
|
|
|
|
+ $data = $fractal->createData($resource)->toArray();
|
|
|
|
+ $data['extra'] = [
|
|
|
|
+ 'filters' => [
|
|
|
|
+ '_id',
|
|
|
|
+ 'behavior_name',
|
|
|
|
+ ],
|
|
|
|
+ 'columns' => [
|
|
|
|
+ '_id',
|
|
|
|
+ 'behavior_name',
|
|
|
|
+ ]
|
|
|
|
+ ];
|
|
|
|
+ return $data;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|