where(function($query) use($conditions){ if (isset($conditions['uid'])){ $query->where('uid', $conditions['uid']); } if (isset($conditions['column'])){ if ($conditions['column']==2){ $query->where('column', 2); // $query->whereRaw(" // object_id in ( select id from specialist_infos where second_id in (12,13) ) // "); }elseif ($conditions['column']==3){ $query->where('column', 3); $query->whereRaw(" object_id NOT IN ( select id from specialist_infos where second_id in (12,13) ) "); }elseif ($conditions['column']==1){ $query->where('column', 1); } } if (isset($conditions['object_id'])){ $query->where('object_id', $conditions['object_id']); } })->groupBy("object_id") ->orderByRaw($sort) ->paginate($limit, $fields); return $this->response($result); } public function sign(string $op, string $task, string $version, array $parameter) { $appid = config('console.thirdScale.appid'); $key = config('console.thirdScale.key'); ksort($parameter); $pStr = ''; foreach ($parameter as $v) { $pStr .= $v; } $str = $parameter['appid'] . $op . $task . $version . $pStr . $key; return md5($str); } public function findBy(array $conditions, array $fields){ $result = BrowseRecord::where(function($query) use($conditions){ if (isset($conditions['id'])){ $query->where('id', $conditions['id']); } if (isset($conditions['uid'])){ $query->where('uid', $conditions['uid']); } if (isset($conditions['column'])){ $query->where('column', $conditions['column']); } if (isset($conditions['object_id'])){ $query->where('object_id', $conditions['object_id']); } })->first($fields); return $result ? $this->response($result) : $this->error()->dataDoesNotExist(); } public function create(array $data) { $result = BrowseRecord::create($data); return $result ? $this->response($result) : $this->error()->fail(); } public function updateBy(array $conditions, array $data) { $result = BrowseRecord::where(function($query) use($conditions){ if (isset($conditions['id'])){ $query->where('id', $conditions['id']); } if (isset($conditions['uid'])){ $query->where('uid', $conditions['uid']); } if (isset($conditions['column'])){ $query->where('column', $conditions['column']); } if (isset($conditions['object_id'])){ $query->where('object_id', $conditions['object_id']); } })->update($data); return $result ? $this->response($result) : $this->error()->fail(); } public function deleteBy(array $conditions) { $result = BrowseRecord::where(function($query) use($conditions){ if (isset($conditions['id'])){ $query->where('id', $conditions['id']); } if (isset($conditions['uid'])){ $query->where('uid', $conditions['uid']); } })->delete(); return $result ? $this->response($result) : $this->error()->fail(); } }