Browse Source

关联分类

moonsflyer 5 tháng trước cách đây
mục cha
commit
51c2df8205
2 tập tin đã thay đổi với 14 bổ sung3 xóa
  1. 1 1
      app/adminapi/lists/info/InfoLists.php
  2. 13 2
      app/common/model/Info.php

+ 1 - 1
app/adminapi/lists/info/InfoLists.php

@@ -61,7 +61,7 @@ class InfoLists extends BaseAdminDataLists
         $lists = Info::where($this->setSearch())
             ->field('id,type,cid,title,synopsis,image,address,phone,latitude,longitude,sort,is_show,create_time,update_time')
             ->limit($this->limitOffset, $this->limitLength)
-//            ->append(['status_desc','type_desc'])
+            ->append(['is_show_desc','type_desc','category'])
             ->order('id', 'desc')
             ->select()
             ->toArray();

+ 13 - 2
app/common/model/Info.php

@@ -20,6 +20,7 @@
 namespace app\common\model;
 
 use app\common\enum\YesNoEnum;
+use app\common\model\InfoCategory;
 use app\common\service\FileService;
 use think\model\concern\SoftDelete;
 
@@ -28,6 +29,16 @@ class Info extends BaseModel
     use SoftDelete;
     protected $deleteTime = 'delete_time';
 
+    /**
+     * @notes 关联分类
+     * @return \think\model\relation\HasMany
+     * @author 段誉
+     * @date 2022/10/19 16:59
+     */
+    public function category()
+    {
+        return $this->hasOne(InfoCategory::class, 'id', 'cid')->field('id,type,name');
+    }
 
     /**
      * @notes 状态获取器
@@ -37,9 +48,9 @@ class Info extends BaseModel
      * @author ljj
      * @date 2021/7/31 3:26 下午
      */
-    public function getStatusDescAttr($value, $data)
+    public function getIsShowDescAttr($value, $data)
     {
-        return YesNoEnum::getStatusDesc($data['status']);
+        return YesNoEnum::getStatusDesc($data['is_show']);
     }
 
     /**