ztt 11 months ago
parent a2d4d99b0c
commit f4463a951c
  1. 8
      app/api/model/ActiveCol.php
  2. 4
      app/api/model/ActiveMain.php
  3. 9
      app/common/model/ActiveCol.php
  4. 4
      app/common/model/ActiveMain.php

@ -20,7 +20,15 @@ use app\common\model\ActiveCol as ActiveColModel;
*/ */
class ActiveCol extends ActiveColModel class ActiveCol extends ActiveColModel
{ {
//追加字段
protected $append = [
'col_pic'
];
public function getColPicAttr($value, $data) {
$file = $this->with(['colImage'])->find();
return $file['col_image_url'];
}
} }

@ -42,11 +42,11 @@ class ActiveMain extends ActiveMainModel
public function getIndexIconAttr($value, $data) { public function getIndexIconAttr($value, $data) {
$file = $this->with('indexImage')->find(); $file = $this->with('indexImage')->find();
return $file['indexImage']['preview_url']; return $file['index_image_url'];
} }
public function getThemePicAttr($value, $data) { public function getThemePicAttr($value, $data) {
$file = $this->with('themeImage')->find(); $file = $this->with('themeImage')->find();
return $file['themeImage']['preview_url']; return $file['theme_image_url'];
} }
} }

@ -28,5 +28,14 @@ class ActiveCol extends BaseModel
// 定义主键 // 定义主键
protected $pk = 'id'; protected $pk = 'id';
/**
* col_image关联
* @return HasOne
*/
public function colImage(): HasOne
{
return $this->hasOne('UploadFile', 'file_id', 'col_image_id')
->bind(['col_image_url' => 'preview_url']);
}
} }

@ -46,7 +46,7 @@ class ActiveMain extends BaseModel
public function indexImage(): HasOne public function indexImage(): HasOne
{ {
return $this->hasOne('UploadFile', 'file_id', 'index_image_id') return $this->hasOne('UploadFile', 'file_id', 'index_image_id')
->bind(['image_url' => 'preview_url']); ->bind(['index_image_url' => 'preview_url']);
} }
/** /**
@ -56,7 +56,7 @@ class ActiveMain extends BaseModel
public function themeImage(): HasOne public function themeImage(): HasOne
{ {
return $this->hasOne('UploadFile', 'file_id', 'theme_image_id') return $this->hasOne('UploadFile', 'file_id', 'theme_image_id')
->bind(['image_url' => 'preview_url']); ->bind(['theme_image_url' => 'preview_url']);
} }
} }

Loading…
Cancel
Save