tp5模型怎麼進行刪除

public function deleteInfo(){
        $info_id = (int) $this->request->param('infoId');
        $InfoModel = new InfoModel();
        $infoData = $InfoModel::where([
            'info_id'=>$info_id
        ])->delete();
        if(!$infoData){
            $send = ['code'=>400,'msg'=>'刪除失敗'];
        }else{
            $send = ['code'=>200,'msg'=>'刪除成功'];
        }
        return json($send);

    }
相關文章
相關標籤/搜索