// +---------------------------------------------------------------------- declare (strict_types=1); namespace app\common\model; use cores\BaseModel; use think\model\relation\BelongsTo; use think\model\relation\HasOne; /** * 文件库分组模型 * Class UploadGroup * @package app\common\model */ class Maintenance extends BaseModel { // 定义表名 protected $name = 'maintenance'; public static function detail(int $articleId, array $with = []) { return self::get($articleId, $with); } public function category(): BelongsTo { $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']); } }