FengR 2 тижнів тому
батько
коміт
0be05e0606
2 змінених файлів з 9 додано та 0 видалено
  1. 2 0
      app/JsonRpc/NewsService.php
  2. 7 0
      app/Model/Article.php

+ 2 - 0
app/JsonRpc/NewsService.php

@@ -435,6 +435,8 @@ class NewsService implements NewsServiceInterface
         },
         'websiteCategory' => function ($query) {
           $query->select('website_id', 'category_id', 'alias');
+        },'user' => function ($query) {
+          $query->select('id', 'nickname');
         }
       ])
       // 构建where条件

+ 7 - 0
app/Model/Article.php

@@ -35,6 +35,13 @@ class Article extends Model
     public function aricleIgnore()
     {
         return $this->belongsTo(ArticleIgnore::class, 'id', 'article_id');
+    }
+     /**
+     * 定义与分类的一对一关系
+     */
+    public function user()
+    {
+        return $this->hasOne(User::class, 'id', 'admin_user_id');
     }
     /**
      * The attributes that are mass assignable.