|
@@ -0,0 +1,432 @@
|
|
|
|
+<?php
|
|
|
|
+namespace App\Repositories\Behavior;
|
|
|
|
+use App\Models\Behavior;
|
|
|
|
+use App\Models\BehaviorOperationLog;
|
|
|
|
+use App\Models\CommentRecord;
|
|
|
|
+use App\Models\GeneralRecord;
|
|
|
|
+use App\Models\Post;
|
|
|
|
+use App\Models\RegisteredRecord;
|
|
|
|
+use App\Models\ReleaseRecord;
|
|
|
|
+use GuzzleHttp\Client;
|
|
|
|
+use GuzzleHttp\Exception\RequestException;
|
|
|
|
+use Illuminate\Support\Carbon;
|
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
|
+use Illuminate\Support\Facades\Log;
|
|
|
|
+use Tymon\JWTAuth\Facades\JWTAuth;
|
|
|
|
+use Dingo\Api\Http\Response;
|
|
|
|
+use Symfony\Component\HttpKernel\Exception\HttpException;
|
|
|
|
+use Illuminate\Database\QueryException;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Created by PhpStorm.
|
|
|
|
+ * User: durong
|
|
|
|
+ * Date: 2019/6/10
|
|
|
|
+ * Time: 上午11:11
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+class BehaviorRepository
|
|
|
|
+{
|
|
|
|
+ public function __construct(Behavior $behavior, BehaviorOperationLog $behaviorOperationLog,
|
|
|
|
+ RegisteredRecord $registeredRecord, CommentRecord $commentRecord,
|
|
|
|
+ GeneralRecord $generalRecord, ReleaseRecord $releaseRecord)
|
|
|
|
+ {
|
|
|
|
+ $this->behavior = $behavior;
|
|
|
|
+ $this->behaviorOperationLog = $behaviorOperationLog;
|
|
|
|
+ $this->registeredRecord = $registeredRecord;
|
|
|
|
+ $this->commentRecord = $commentRecord;
|
|
|
|
+ $this->generalRecord = $generalRecord;
|
|
|
|
+ $this->releaseRecord = $releaseRecord;
|
|
|
|
+ //初始化virus域名
|
|
|
|
+ $this->client = new Client([
|
|
|
|
+ 'base_uri' => config('constants.VIRUS_URL'),
|
|
|
|
+ 'timeout' => 3
|
|
|
|
+ ]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function lists($request)
|
|
|
|
+ {
|
|
|
|
+ try {
|
|
|
|
+ $signKey = [
|
|
|
|
+ 'app' => config('constants.VIRUS_APP_ID')
|
|
|
|
+ ];
|
|
|
|
+ ksort($signKey);
|
|
|
|
+ $signKey = urldecode(http_build_query($signKey));
|
|
|
|
+ $sign = md5(config('constants.VIRUS_APP_SECRET') . $signKey);
|
|
|
|
+
|
|
|
|
+ $response = $this->client->request('GET', 'behaviorList', [
|
|
|
|
+ 'headers' => [
|
|
|
|
+ 'Content-Type' => 'application/json',
|
|
|
|
+ 'app' => config('constants.VIRUS_APP_ID'),
|
|
|
|
+ 'sign' => $sign
|
|
|
|
+ ]
|
|
|
|
+ ]);
|
|
|
|
+ $res = json_decode($response->getBody()->getContents(), true);
|
|
|
|
+ $res = $res ? $res['behaviors'] : [];
|
|
|
|
+ } catch (RequestException $exception) {
|
|
|
|
+ $res = [
|
|
|
|
+ 'returnCode' => '-1',
|
|
|
|
+ 'errMsg' => '网络超时' . $exception->getMessage()
|
|
|
|
+ ];
|
|
|
|
+ Log::debug('获取virus行为列表:' . $exception->getMessage());
|
|
|
|
+ }
|
|
|
|
+ //已登记行为
|
|
|
|
+ $registered_bahavior = $this->behavior->get();
|
|
|
|
+ $registered_bahaviors = $registered_bahavior->toArray();
|
|
|
|
+
|
|
|
|
+ foreach ($registered_bahaviors as $key => $val) {
|
|
|
|
+ $registered_bahaviors[$key]['behavior_status'] = 1;//已登记
|
|
|
|
+ unset($registered_bahaviors[$key]['behavior_action_id']);
|
|
|
|
+ }
|
|
|
|
+ $virus_behavior_id = array_column($registered_bahaviors, 'virus_behavior_id');
|
|
|
|
+
|
|
|
|
+ $new_res = [];
|
|
|
|
+ //行为列表去重
|
|
|
|
+ foreach ($res as $k => $v) {
|
|
|
|
+ if (isset($v['_id']) && !empty($virus_behavior_id)) {
|
|
|
|
+ $res[$k]['behavior_status'] = 0;//未登记
|
|
|
|
+ $res[$k]['behavior_flag'] = $v['behavior_flag'];
|
|
|
|
+ $res[$k]['behavior_identification'] = $v['behavior_flag'];
|
|
|
|
+ unset($res[$k]['behavior_flag']);
|
|
|
|
+ if (in_array($v['_id'], $virus_behavior_id)) {
|
|
|
|
+ unset($res[$k]);
|
|
|
|
+ }
|
|
|
|
+ $new_res = array_merge($res, $registered_bahaviors);
|
|
|
|
+
|
|
|
|
+ } elseif (!isset($v['_id']) && $virus_behavior_id) {
|
|
|
|
+ $new_res = $registered_bahaviors;
|
|
|
|
+ } elseif (isset($v['_id']) && empty($virus_behavior_id)) {
|
|
|
|
+ $res[$k]['behavior_status'] = 0;//未登记
|
|
|
|
+ $res[$k]['behavior_flag'] = $v['behavior_flag'];
|
|
|
|
+ $res[$k]['behavior_identification'] = $v['behavior_flag'];
|
|
|
|
+ unset($res[$k]['behavior_flag']);
|
|
|
|
+ $new_res = $res;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ $new_re = [];
|
|
|
|
+ //根据行为ID筛选
|
|
|
|
+ if (isset($request['virus_behavior_id'])) {
|
|
|
|
+ foreach ($new_res as $k => $v) {
|
|
|
|
+ if (isset($v['id']) && $v['id'] != $request['virus_behavior_id']) {
|
|
|
|
+ unset($new_res[$k]);
|
|
|
|
+ $new_re = array_merge($new_res);
|
|
|
|
+ } elseif (isset($v['_id']) && $v['_id'] != $request['virus_behavior_id']) {
|
|
|
|
+ unset($new_res[$k]);
|
|
|
|
+ $new_re = array_merge($new_res);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return $new_re;
|
|
|
|
+ }
|
|
|
|
+ //根据行为状态(类型)筛选
|
|
|
|
+ if (isset($request['behavior_status'])) {
|
|
|
|
+ foreach ($new_res as $kk => $vv) {
|
|
|
|
+ if (isset($vv['behavior_status']) && $vv['behavior_status'] != $request['behavior_status']) {
|
|
|
|
+ unset($new_res[$kk]);
|
|
|
|
+ $new_re = array_merge($new_res);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return $new_re;
|
|
|
|
+ }
|
|
|
|
+ //根据绑定的动作ID筛选(暂时取消)
|
|
|
|
+// if (isset($request['behavior_action_id'])){
|
|
|
|
+// foreach ($new_res as $key=>$val) {
|
|
|
|
+// if (isset($val['behavior_action_id']) && ($val['behavior_action_id'] != $request['behavior_action_id'])) {
|
|
|
|
+// unset($new_res[$key]);
|
|
|
|
+//// $new_re = array_merge($new_res);
|
|
|
|
+// } elseif (!isset($val['behavior_action_id'])) {
|
|
|
|
+// unset($new_res[$key]);
|
|
|
|
+//// $new_re = array_merge($new_res);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// return $new_re;
|
|
|
|
+// }
|
|
|
|
+ //根据行为名称筛选
|
|
|
|
+ if (isset($request['name'])) {
|
|
|
|
+ foreach ($new_res as $key => $val) {
|
|
|
|
+ if (isset($val['name']) && strpos($val['name'], $request['name']) !== false) {
|
|
|
|
+ $new_re[] = $new_res[$key];
|
|
|
|
+ }
|
|
|
|
+ if (isset($val['behavior_name']) && strpos($val['behavior_name'], $request['name']) !== false) {
|
|
|
|
+ $new_re[] = $new_res[$key];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return $new_re;
|
|
|
|
+ }
|
|
|
|
+ return $new_res;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function create($request)
|
|
|
|
+ {
|
|
|
|
+ $behavior_name = $this->behavior->where(['name' => $request['name']])->first();
|
|
|
|
+ if ($behavior_name) {
|
|
|
|
+ throw new HttpException(500, '该行为已存在');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (isset($request['allotted_quantity_rule']) && isset($request['rainbow_beans'])) {
|
|
|
|
+ $rule = $request['allotted_quantity_rule'];
|
|
|
|
+ $rainbow_beans = $request['rainbow_beans'];
|
|
|
|
+ $count = 0;
|
|
|
|
+ if (count($rule) == count($rule, 1)) {
|
|
|
|
+ $count = array_sum($rule);
|
|
|
|
+ $request['allotted_quantity_rule'] = array_map('intval', $request['allotted_quantity_rule']);
|
|
|
|
+ if ($count > $rainbow_beans) {
|
|
|
|
+ throw new HttpException(500, '唯一行为-分配总数不能大于行为生成彩虹豆总数');
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ foreach ($request['allotted_quantity_rule'] as $key => $value) {
|
|
|
|
+ $count += $value['bean'];
|
|
|
|
+ $request['allotted_quantity_rule'][$key] = array_map('intval', $value);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ if ($count > $rainbow_beans) {
|
|
|
|
+ throw new HttpException(500, '多级行为-分配总数不能大于行为生成彩虹豆总数');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $data = [
|
|
|
|
+ 'virus_behavior_id' => $request['virus_behavior_id'],
|
|
|
|
+ 'name' => $request['name'],
|
|
|
|
+ 'behavior_level' => $request['behavior_level'],
|
|
|
|
+ 'behavior_cycle_type' => $request['behavior_cycle_type'],
|
|
|
|
+ 'is_open' => 0,
|
|
|
|
+ 'behavior_action_id' => isset($request['behavior_action_id']) ? $request['behavior_action_id'] : '',
|
|
|
|
+ 'behavior_cycle' => isset($request['behavior_cycle']) ? $request['behavior_cycle'] : '',
|
|
|
|
+ 'behavior_binding_users' => isset($request['behavior_binding_users']) ? $request['behavior_binding_users'] : 0,
|
|
|
|
+ 'physical_strength' => isset($request['physical_strength']) ? $request['physical_strength'] : 0,
|
|
|
|
+ 'rainbow_beans' => isset($request['rainbow_beans']) ? $request['rainbow_beans'] : 0,
|
|
|
|
+ 'grant_rainbow_beans' => isset($request['grant_rainbow_beans']) ? $request['grant_rainbow_beans'] : 0,
|
|
|
|
+ 'remarks' => isset($request['remarks']) ? $request['remarks'] : '',
|
|
|
|
+ 'behavioral_cycle_start_time' => isset($request['behavioral_cycle_start_time']) ? $request['behavioral_cycle_start_time'] : null,
|
|
|
|
+ 'behavioral_cycle_end_time' => isset($request['behavioral_cycle_end_time']) ? $request['behavioral_cycle_end_time'] : null,
|
|
|
|
+ 'allotted_quantity_rule' => isset($request['allotted_quantity_rule']) ? json_encode($request['allotted_quantity_rule']) : '',
|
|
|
|
+ 'behavior_identification' => isset($request['behavior_identification']) ? $request['behavior_identification'] : '',
|
|
|
|
+ 'trigger_times' => isset($request['trigger_times']) ? $request['trigger_times'] : 0,
|
|
|
|
+ 'effective_trigger' => isset($request['effective_trigger']) ? $request['effective_trigger'] : 0,
|
|
|
|
+ 'relative_series' => isset($request['relative_series']) ? $request['relative_series'] : 0,
|
|
|
|
+ 'absolute_progression' => isset($request['absolute_progression']) ? $request['absolute_progression'] : 0,
|
|
|
|
+ ];
|
|
|
|
+ DB::beginTransaction();
|
|
|
|
+ try {
|
|
|
|
+ $res = $this->behavior->create($data);
|
|
|
|
+ if ($res) {
|
|
|
|
+ $token = JWTAuth::decode(JWTAuth::getToken());
|
|
|
|
+ $uid = $token['user']->id;
|
|
|
|
+ $username = $token['user']->username;
|
|
|
|
+ $cerate_bahavior_data = [
|
|
|
|
+ 'operator_id' => $uid,
|
|
|
|
+ 'behavior_id' => $res['id'],
|
|
|
|
+ 'username' => $username,
|
|
|
|
+ 'content' => '创建' . $request['name'] . '行为',
|
|
|
|
+ 'type' => 0,
|
|
|
|
+ 'created_at' => date('Y-m-d H:i:s'),
|
|
|
|
+ 'updated_at' => date('Y-m-d H:i:s')
|
|
|
|
+ ];
|
|
|
|
+ $result = $this->behaviorOperationLog->insert($cerate_bahavior_data);
|
|
|
|
+ if (!$result) {
|
|
|
|
+ throw new HttpException(500, '操作日志记录失败');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ DB::commit();
|
|
|
|
+ return Response::create();
|
|
|
|
+
|
|
|
|
+ } catch (QueryException $exception) {
|
|
|
|
+ DB::rollBack();
|
|
|
|
+ Log::debug('注册行为:' . $exception->getMessage());
|
|
|
|
+ return Response::create([
|
|
|
|
+ 'message' => '添加失败,请重试',
|
|
|
|
+ 'error' => $exception->getMessage(),
|
|
|
|
+ 'status_code' => 500
|
|
|
|
+ ]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function edit($request)
|
|
|
|
+ {
|
|
|
|
+ $behavior_id = $this->behavior->find($request['id']);
|
|
|
|
+ if ($behavior_id->is_open == 1) {
|
|
|
|
+ throw new HttpException(500, '无法编辑已经在记录的行为');
|
|
|
|
+ }
|
|
|
|
+ if (isset($request['allotted_quantity_rule']) && isset($request['rainbow_beans'])) {
|
|
|
|
+
|
|
|
|
+ $rule = $request['allotted_quantity_rule'];
|
|
|
|
+ $rainbow_beans = $request['rainbow_beans'];
|
|
|
|
+ $count = 0;
|
|
|
|
+ if (count($rule) == count($rule, 1)) {
|
|
|
|
+ $count = array_sum($rule);
|
|
|
|
+ $request['allotted_quantity_rule'] = array_map('intval', $request['allotted_quantity_rule']);
|
|
|
|
+ if ($count > $rainbow_beans) {
|
|
|
|
+ throw new HttpException(500, '唯一行为-分配总数不能大于行为生成彩虹豆总数');
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ foreach ($request['allotted_quantity_rule'] as $key => $value) {
|
|
|
|
+ $count += $value['bean'];
|
|
|
|
+ $request['allotted_quantity_rule'][$key] = array_map('intval', $value);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ if ($count > $rainbow_beans) {
|
|
|
|
+ throw new HttpException(500, '多级行为-分配总数不能大于行为生成彩虹豆总数');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $update_bahavior = [
|
|
|
|
+ 'virus_behavior_id' => $request['virus_behavior_id'],
|
|
|
|
+ 'name' => $request['name'],
|
|
|
|
+ 'behavior_level' => $request['behavior_level'],
|
|
|
|
+ 'behavior_cycle_type' => $request['behavior_cycle_type'],
|
|
|
|
+ 'is_open' => 0,
|
|
|
|
+ 'behavior_cycle' => isset($request['behavior_cycle']) ? $request['behavior_cycle'] : '',
|
|
|
|
+ 'behavior_binding_users' => isset($request['behavior_binding_users']) ? $request['behavior_binding_users'] : 0,
|
|
|
|
+ 'physical_strength' => isset($request['physical_strength']) ? $request['physical_strength'] : 0,
|
|
|
|
+ 'rainbow_beans' => isset($request['rainbow_beans']) ? $request['rainbow_beans'] : 0,
|
|
|
|
+ 'grant_rainbow_beans' => isset($request['grant_rainbow_beans']) ? $request['grant_rainbow_beans'] : 0,
|
|
|
|
+ 'remarks' => isset($request['remarks']) ? $request['remarks'] : '',
|
|
|
|
+ 'behavioral_cycle_start_time' => isset($request['behavioral_cycle_start_time']) ? $request['behavioral_cycle_start_time'] : null,
|
|
|
|
+ 'behavioral_cycle_end_time' => isset($request['behavioral_cycle_end_time']) ? $request['behavioral_cycle_end_time'] : null,
|
|
|
|
+ 'allotted_quantity_rule' => isset($request['allotted_quantity_rule']) ? json_encode($request['allotted_quantity_rule']) : '',
|
|
|
|
+ 'behavior_identification' => isset($request['behavior_identification']) ? $request['behavior_identification'] : '',
|
|
|
|
+ 'trigger_times' => isset($request['trigger_times']) ? $request['trigger_times'] : 0,
|
|
|
|
+ 'effective_trigger' => isset($request['effective_trigger']) ? $request['effective_trigger'] : 0,
|
|
|
|
+ 'relative_series' => isset($request['relative_series']) ? $request['relative_series'] : 0,
|
|
|
|
+ 'absolute_progression' => isset($request['absolute_progression']) ? $request['absolute_progression'] : 0,
|
|
|
|
+ 'updated_at' => date('Y-m-d H:i:s')
|
|
|
|
+ ];
|
|
|
|
+ DB::beginTransaction();
|
|
|
|
+ try {
|
|
|
|
+ $res = $this->behavior->where('id', $request['id'])->update($update_bahavior);
|
|
|
|
+ if ($res) {
|
|
|
|
+ $token = JWTAuth::decode(JWTAuth::getToken());
|
|
|
|
+ $uid = $token['user']->id;
|
|
|
|
+ $username = $token['user']->username;
|
|
|
|
+ $cerate_bahavior_data = [
|
|
|
|
+ 'operator_id' => $uid,
|
|
|
|
+ 'behavior_id' => $request['id'],
|
|
|
|
+ 'username' => $username,
|
|
|
|
+ 'content' => json_encode($update_bahavior),
|
|
|
|
+ 'type' => 1,
|
|
|
|
+ 'created_at' => date('Y-m-d H:i:s'),
|
|
|
|
+ 'updated_at' => date('Y-m-d H:i:s')
|
|
|
|
+ ];
|
|
|
|
+ $result = $this->behaviorOperationLog->insert($cerate_bahavior_data);
|
|
|
|
+ if (!$result) {
|
|
|
|
+ throw new HttpException(500, '操作日志记录失败');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ DB::commit();
|
|
|
|
+ return Response::create();
|
|
|
|
+
|
|
|
|
+ } catch (QueryException $exception) {
|
|
|
|
+ DB::rollBack();
|
|
|
|
+ Log::debug('编辑行为:' . $exception->getMessage());
|
|
|
|
+ return Response::create([
|
|
|
|
+ 'message' => '编辑失败,请重试',
|
|
|
|
+ 'error' => $exception->getMessage(),
|
|
|
|
+ 'status_code' => 500
|
|
|
|
+ ]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function editStatus($request)
|
|
|
|
+ {
|
|
|
|
+ $behavior = $this->behavior->find($request['id']);
|
|
|
|
+
|
|
|
|
+ $behavior_array = [
|
|
|
|
+ 'is_open' => $request['is_open'],
|
|
|
|
+ 'updated_at' => date('Y-m-d H:i:s')
|
|
|
|
+ ];
|
|
|
|
+ if ($request['is_open'] == 0) {
|
|
|
|
+ $is_open = '关闭';
|
|
|
|
+ } else {
|
|
|
|
+ $is_open = '开启';
|
|
|
|
+ }
|
|
|
|
+ $behavior_name = $behavior->name;
|
|
|
|
+
|
|
|
|
+ DB::beginTransaction();
|
|
|
|
+ try {
|
|
|
|
+ $res = $behavior->where('id', $request['id'])->update($behavior_array);
|
|
|
|
+ if ($res) {
|
|
|
|
+ $token = JWTAuth::decode(JWTAuth::getToken());
|
|
|
|
+ $uid = $token['user']->id;
|
|
|
|
+ $username = $token['user']->username;
|
|
|
|
+ $cerate_bahavior_data = [
|
|
|
|
+ 'operator_id' => $uid,
|
|
|
|
+ 'behavior_id' => $request['id'],
|
|
|
|
+ 'username' => $username,
|
|
|
|
+ 'content' => $is_open . '了' . $behavior_name . '行为',
|
|
|
|
+ 'type' => 2,
|
|
|
|
+ 'created_at' => date('Y-m-d H:i:s'),
|
|
|
|
+ 'updated_at' => date('Y-m-d H:i:s')
|
|
|
|
+ ];
|
|
|
|
+ $result = $this->behaviorOperationLog->insert($cerate_bahavior_data);
|
|
|
|
+ if (!$result) {
|
|
|
|
+ throw new HttpException(500, '操作日志记录失败');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ DB::commit();
|
|
|
|
+ return Response::create();
|
|
|
|
+
|
|
|
|
+ } catch (QueryException $exception) {
|
|
|
|
+ DB::rollBack();
|
|
|
|
+ Log::debug('修改状态行为:' . $exception->getMessage());
|
|
|
|
+ return Response::create([
|
|
|
|
+ 'message' => '修改状态失败,请重试',
|
|
|
|
+ 'error' => $exception->getMessage(),
|
|
|
|
+ 'status_code' => 500
|
|
|
|
+ ]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function dataList($request)
|
|
|
|
+ {
|
|
|
|
+ $perPage = isset($request['per_page']) ? $request['per_page'] : 20;
|
|
|
|
+ $where = [];
|
|
|
|
+ if(isset($request['id'])){
|
|
|
|
+ $where[] = ['id',$request['id']];
|
|
|
|
+ }
|
|
|
|
+ if(isset($request['is_open'])){
|
|
|
|
+ $where[] = ['is_open',$request['is_open']];
|
|
|
|
+ }
|
|
|
|
+ //行为级别唯一/多级筛选
|
|
|
|
+ if(isset($request['behavior_level'])){
|
|
|
|
+ $where[] = ['behavior_level',$request['behavior_level']];
|
|
|
|
+ }
|
|
|
|
+ if(isset($request['name'])){
|
|
|
|
+ $where[] = ['name', 'like', "%{$request['name']}%"];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $sort = 'desc';
|
|
|
|
+ $filed = 'id';
|
|
|
|
+ if(isset($request['search']) && isset($request['sort'])){
|
|
|
|
+ $filed = $this->check_search($request['search']);
|
|
|
|
+ $sort = $request['sort'] == 0 ? 'desc' : 'asc';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $this->behavior->where($where)->orderBy($filed,$sort)->paginate($perPage);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private function check_search($search)
|
|
|
|
+ {
|
|
|
|
+ $result = "";
|
|
|
|
+ switch ($search) {
|
|
|
|
+ case 'trigger_times':
|
|
|
|
+ $result = $search;
|
|
|
|
+ break;
|
|
|
|
+ case 'effective_trigger':
|
|
|
|
+ $result = $search;
|
|
|
|
+ break;
|
|
|
|
+ case 'absolute_progression':
|
|
|
|
+ $result = $search;
|
|
|
|
+ break;
|
|
|
|
+ case 'physical_strength':
|
|
|
|
+ $result = $search;
|
|
|
|
+ break;
|
|
|
|
+ case 'grant_rainbow_beans':
|
|
|
|
+ $result = $search;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ return $result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|