redis
$redisKey = "yixinzuqiu:houtai:column:getMatchListBySpecialColumn:{$userId}"; $data = Redis::connection('plan')->get($redisKey); if ($data) { $data = json_decode($data); }else{ Redis::connection('plan')->setex($redisKey, 60, json_encode($data)); } //get Redis::connection('plan')->get($redisKey)//setex Redis::connection('plan')->setex($redisKey, 60, json_encode($data));
Mysql
idArr 去重
$idArr = array_unique(array_column($data, 'id')); $bUserList = (new BUserModel())->getListByDepartmentIdArr($idArr);
打印最后一次执行的sql
DB::connection()->enableQueryLog(); var_dump(DB::getQueryLog()); die(); //whereor orwhere orwhereraw if ($titlecontent = $this->request->get('titlecontent')){ if (!$this->request->get('title')){ $msg = $msg->where('title', 'like', '%' . $titlecontent . '%'); } $msg = $msg->orWhereRaw('(content like ? and status = ?)', ["%{$titlecontent}%", 1]); } //单个值 $tmps['department_name'] = HoutaiDepartment::where('id', $tmp['department_id'])->first()['name']; //事务 DB::beginTransaction(); try { $ht = BUserModel::where('id', $user_id)->update($data); if (HoutaiUserInfo::where('user_id', $user_id)->first()) HoutaiUserInfo::where('user_id', $user_id)->update($params); else { $params['user_id'] = $user_id; HoutaiUserInfo::create($params); } DB::commit(); return json_encode(['status' => 'success']); } catch (\Exception $e) { DB::rollBack(); return json_encode(['error' => '修改用户失败']); } whereIn('id', $idArr) ->get(); $data = []; if ($list) { $list = $list->toArray(); foreach ($list as $value) { $data[$value['id']] = $value; } } return $data; } }
调整到另外一个路由
return route('FilePull', $arr); Route::get('file', [ 'as' => 'FilePull', 'alias' => '获取文件', 'uses' => 'FileController@getFile' ]);
删除和软删除
Cases::find($id)->delete(); Cases::destroy($id); //软删除恢复 // Cases::find($id)->restore();
永久删除模型
// 强制删除单个模型实例... $flight->forceDelete(); // 强制删除所有关联模型... $flight->history()->forceDelete();
给参数默认值
$request->input('company_name',’sdfsaf’);
服务器配置Nginx
try_files $uri $uri/ /index.php?$query_string;