腾讯云智聆口语评测bug
这是我人生中第一次找到sdk的bug 开心 哈哈哈哈
轮询的时候无返回结果 status是finished 导致业务无法继续
这是我人生中第一次找到sdk的bug 开心 哈哈哈哈
轮询的时候无返回结果 status是finished 导致业务无法继续
$content=str_replace("/ /",'',$content);
$content=str_replace(" ",'',$content);
这两种过滤空格的方法 是无法过滤 的!!! utf-8的全角空格
$log = Invite::where('from_teacher_id',session('teacher')['id'])
->with('hasTeacher')
->with('hasBanjis')
->with('hasBanjis.hasBanjiStudents')
->with('hasBanjis.hasTasks.hasStudentHomeworks')
->get();
如果是hasmany就用循环,如果是hasOne就直接->用
public function up()
{
Schema::create('activitys', function (Blueprint $table) {
$table->increments('activity_id')->comment('活动表');
$table->timestamps();
});
DB::statement("ALTER TABLE `tbl_activitys` comment'活动表'");//表注释一定加上前缀
}
public function headingCode()
{
list($msec, $sec) = explode(' ', microtime());
$msectime = (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000);
$msectime = substr(str_shuffle($msectime), -6);
$banji = Table::where('heading_code', $msectime)->first();
if($banji) {
$this->headingCode();
}
return $msectime;
}
这是一个递归算法能随机6位数,并且去数据库中查询是否已有,没有的话就返回
但是这里有个问题, 就是递归时实际上第一个方法的变量还在内存中没有销毁,第二次进来的时候虽然变量都叫一个名字,但是内存中分配的是不同的空间进行存储,所以随后会出现只返回第一次的$msectime,解决方法如下
public function headingCode()
{
list($msec, $sec) = explode(' ', microtime());
$msectime = (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000);
$msectime = substr(str_shuffle($msectime), -6);
$banji = Banji::where('heading_code', $msectime)->first();
if($banji) {
$msectime = $this->headingCode();
}
return $msectime;
}
preg_split('/(?<!^)(?!$)/u', $content)
php artisan make:model StudentHearRecord -m
创建的数据库迁移文件会自动加s
有目录的写法
php artisan make:model /Model/CustomerService/LingShengRecord -m
$map['task_id'] = $request->task_id;
$finished = $request->finished;
$isShow = $request->is_show;
$isAll = $request->is_all ? $request->is_all: 0;
$limit = $request->limit ? $request->limit : 6;
if($isShow==1) {
$finished = '';
}
$data = TableModel::where($map)
->when($finished == 2 , function ($query) use ($finished) {// 未完成
return $query->where('finished','!=','1');
})
->when($finished == 1 , function ($query) use ($finished) {// 已完成
return $query->where('finished','1');
})
->when($isShow == 1 , function ($query) use ($isShow) {//
return $query->where('read_time','=','null');
})
->select('*')
->orderBy('num', 'desc')
->with('hasUser')
->when($isAll == 1 , function ($query) use ($isAll) {// 没有分页
return $query->get();
})
->when($isAll != 1 , function ($query) use ($isAll,$limit) {// 有分页
return $query->paginate($limit);
});
$data = StudentHomework::where($map)
->with('hasTask')
->whereHas('hasTask',function ($query){
$query->where('begin_date','<=',date('Y-m-d',time()))
->where('end_date','>=',date('Y-m-d',time()));
return $query;//因为这个闭包不是数组所以需要返回
})
->with('hasHomeWork')
->orderBy('id','desc')
->paginate($limit);
$keyword = $this->filters['keyword'];
$options = $this->parseOptions();
$datas = TableModel::with('hasBook')
->with('hasGradeCell.hasGrade')
->when($keyword,function($query)use($keyword){
return $query->where('title','like','%'.$keyword.'%');
})
->when($options,function ($query) use ($options){
if (isset($options['cell_id'])) {
return $query->where('cell_id', $options['cell_id']);
}
if (isset($options['grade_id'])) {
return $query->whereHas('hasGradeCell',function ($query) use ($options){
return $query->whereHas('hasGrade',function ($query) use ($options){
return $query->where('id',$options['grade_id']);
});
});
}
});
$counts = $datas->count();
$datas = $datas->where('type', 1)
->orderBy($this->filters['sort'], $this->filters['sort_by'])
->paginate($this->filters['limit'])
->appends($this->filters);