v1.0
bruce 8 months ago
parent 4847408e58
commit 6a40626fe8
  1. 8
      app/common/model/Maintenance.php
  2. 2
      app/common/model/MaintenanceCategory.php
  3. 7
      app/store/model/Maintenance.php

@ -14,6 +14,7 @@ namespace app\common\model;
use cores\BaseModel;
use think\model\relation\BelongsTo;
use think\model\relation\HasOne;
/**
* 文件库分组模型
@ -36,4 +37,11 @@ class Maintenance extends BaseModel
$module = self::getCalledModule();
return $this->BelongsTo("app\\{$module}\\model\\MaintenanceCategory", 'category_id');
}
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 +47,7 @@ class MaintenanceCategory extends BaseModel
public function getList(array $where = []): \think\Collection
{
return $this->where($where)
->with(['maintenances'])
->with(['maintenances.catImg'])
->order(['sort', $this->getPk()])
->select();
}

@ -109,11 +109,4 @@ class Maintenance extends MaintenanceModel
{
return (new static)->where($where)->where('is_delete', '=', 0)->count();
}
public function catImg(): HasOne
{
$module = self::getCalledModule();
return $this->hasOne("app\\{$module}\\model\\UploadFile", 'file_id', 'img_id')
->bind(['img_url' => 'preview_url']);
}
}

Loading…
Cancel
Save