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.
56 lines
1.4 KiB
56 lines
1.4 KiB
<?php
|
|
namespace app\integral\model;
|
|
|
|
use think\model\concern\SoftDelete;
|
|
|
|
class IntegralConfigCarousel extends Base
|
|
{
|
|
use SoftDelete;
|
|
|
|
/**
|
|
* API-获取轮播图
|
|
* @date 2021-06-01
|
|
*/
|
|
public function getCarousel()
|
|
{
|
|
$where = [
|
|
['uid', '=', $this->mid]
|
|
];
|
|
return $this->where($where)->field('image,link_url')->order('sort desc')->select()->toArray();
|
|
}
|
|
|
|
/**
|
|
* 修改轮播图
|
|
* @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;
|
|
}
|
|
}
|
|
} |