v1.0
bruce 8 months ago
parent 19232f28a4
commit 61cf9835dc
  1. 10
      app/common/model/MaintenanceCategory.php

@ -36,6 +36,14 @@ class MaintenanceCategory extends BaseModel
return static::get($categoryId);
}
public function catImg(): HasOne
{
$module = self::getCalledModule();
return $this->hasOne("app\\{$module}\\model\\UploadFile", 'file_id', 'img_id')
->bind(['img_url' => 'preview_url']);
}
/**
* 获取列表
@ -47,7 +55,7 @@ class MaintenanceCategory extends BaseModel
*/
public function getList(array $where = []): \think\Collection
{
return $this->where($where)
return $this->where($where)->with(['catImg'])
->order(['sort', $this->getPk()])
->select();
}

Loading…
Cancel
Save