|
|
|
@ -13,6 +13,7 @@ declare (strict_types=1); |
|
|
|
|
namespace app\store\model; |
|
|
|
|
|
|
|
|
|
use app\common\model\Maintenance as MaintenanceModel; |
|
|
|
|
use think\model\relation\HasOne; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 文章模型 |
|
|
|
@ -41,7 +42,7 @@ class Maintenance extends MaintenanceModel |
|
|
|
|
$params['status'] > -1 && $filter[] = ['status', '=', $params['status']]; |
|
|
|
|
$params['categoryId'] > 0 && $filter[] = ['category_id', '=', $params['categoryId']]; |
|
|
|
|
// 查询列表数据 |
|
|
|
|
$data = $this->where($filter) |
|
|
|
|
$data = $this->where($filter)->with(['catImg']) |
|
|
|
|
->where('is_delete', '=', 0) |
|
|
|
|
->order(['sort' => 'asc', 'create_time' => 'desc']) |
|
|
|
|
->paginate(15); |
|
|
|
@ -108,4 +109,11 @@ 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']); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|