作者 开飞机的舒克

轮播图修改

@@ -125,13 +125,10 @@ class Index extends Api @@ -125,13 +125,10 @@ class Index extends Api
125 if (empty($id)) { 125 if (empty($id)) {
126 $this->error('参数错误', ['status' => 2]); 126 $this->error('参数错误', ['status' => 2]);
127 } 127 }
128 - $data = Banner::where('id', $id) 128 + $model = new Banner();
  129 + $data = collection($model->where('id', $id)
129 ->order('createtime DESC') 130 ->order('createtime DESC')
130 - ->select();  
131 - foreach ($data as $k => $v) {  
132 - $data[$k]['images'] = cdnurl($v['images'], true);  
133 - $data[$k]['details'] = strip_tags($v['details']);  
134 - } 131 + ->select())->toArray();
135 $this->success('获取轮播图详情成功', $data); 132 $this->success('获取轮播图详情成功', $data);
136 } 133 }
137 134
@@ -35,6 +35,21 @@ class Banner extends Model @@ -35,6 +35,21 @@ class Banner extends Model
35 return isset($list[$value]) ? $list[$value] : ''; 35 return isset($list[$value]) ? $list[$value] : '';
36 } 36 }
37 37
  38 + public function getImagesAttr($value, $data)
  39 + {
  40 + $list = explode(',', $data['images']);
  41 + foreach ($list as $k => $v) {
  42 + $value = cdnurl($v['images'], true);
  43 + }
  44 + return $value;
  45 + }
  46 +
  47 + public function getDetailsAttr($value, $data)
  48 + {
  49 + $value = strip_tags($data['details']);
  50 + return $value;
  51 + }
  52 +
38 public function getCreatetimeTextAttr($value, $data) 53 public function getCreatetimeTextAttr($value, $data)
39 { 54 {
40 $value = $value ? $value : ($data['createtime'] ?? ""); 55 $value = $value ? $value : ($data['createtime'] ?? "");
@@ -5920,7 +5920,7 @@ @@ -5920,7 +5920,7 @@
5920 5920
5921 </div> 5921 </div>
5922 <div class="col-md-6" align="right"> 5922 <div class="col-md-6" align="right">
5923 - Generated on 2023-04-04 11:43:29 <a href="./" target="_blank">校园活动</a> 5923 + Generated on 2023-04-04 13:40:06 <a href="./" target="_blank">校园活动</a>
5924 </div> 5924 </div>
5925 </div> 5925 </div>
5926 5926