作者 刘锟

合并分支 'akun' 到 'master'

Akun



查看合并请求 !3362
... ... @@ -9,6 +9,7 @@
namespace App\Http\Logic\Aside\Geo;
use App\Helper\Arr;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Geo\GeoPlatform;
use App\Models\Geo\GeoQuestion;
... ... @@ -189,8 +190,30 @@ class GeoQuestionLogic extends BaseLogic
]);
//删除问题
$lists = $this->model->select(['id','question'])->where('project_id', $project_id)->whereJsonContains('question', [['Value' => $question]])->get()->toArray();
dd($lists);
$lists = $this->model->select(['id','question'])->where('project_id', $project_id) ->whereRaw('JSON_CONTAINS(`question`,\'"'.$question.'"\')')->get();
if($lists->count() > 0){
foreach ($lists as $item){
if(count($item['question']) == 1){
//主问题只包含这一个子问题,直接删除主问题
$item->delete();
}else{
//主问题包含多个问题,只删除当前问题,保留剩下问题
$new_question = [];
foreach ($item['question'] as $vq){
if($vq == $question){
continue;
}
$new_question[] = $vq;
}
if(empty($new_question)){
$item->delete();
}else{
$item->question = Arr::a2s($new_question);
$item->save();
}
}
}
}
DB::commit();
}catch (\Exception $e){
... ...