You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.1 KiB
45 lines
1.1 KiB
<?php
|
|
|
|
namespace app\fire\model;
|
|
|
|
use think\model\concern\SoftDelete;
|
|
|
|
class FireCarousel extends Base
|
|
{
|
|
use SoftDelete;
|
|
|
|
/**
|
|
* 修改轮播图
|
|
* @param $data
|
|
* @return bool
|
|
*/
|
|
public function dataUpdateByAll($data) {
|
|
if (empty($data)) {
|
|
return false;
|
|
} else {
|
|
$this->startTrans();
|
|
foreach ($data as $key => $value) {
|
|
if ($value['id'] != ""&&$value['image']!="") {
|
|
//修改数据
|
|
$res = $this->dataUpdate($value);
|
|
}else{
|
|
if($value['image']==''){
|
|
//删除数据
|
|
$res = $this->destroy(['id'=>$value['id']]);
|
|
}else{
|
|
//新增数据
|
|
unset($value['id']);
|
|
$res = $this->dataUpdate($value);
|
|
}
|
|
}
|
|
if ($res === false) {
|
|
$this->rollBack();
|
|
return false;
|
|
}
|
|
}
|
|
$this->commit();
|
|
|
|
return true;
|
|
}
|
|
}
|
|
} |