// 更新前
Ad::beforeUpdate(function ($ad) {
$data = input('post.');
if($data['type']=='1'){
if($_FILES['img_src']['tmp_name']){
$commons=new ComController;
$upname=$commons->uploadImg('img_src',ADUPLOAD);
// 将参数传回
$ad['img_src']=str_replace('\\','/',$upname);
}
}
// 修改广告状态
if($data['statues']=='1'){
model('ad')->where('statues','1')->where('adpos_id',$data['adpos_id'])->update(['statues' => '0']);
}
});
controller方法
if($request->isPost()){
$data = $request->param();
if(model('ad')->update($data)){
$this->success('广告修改成功!');
}else{
$this->error('广告修改失败!');
}
}
最佳答案