소스 검색

修改b端:获取资讯列表的接口---还原代码---新闻表模型适应性修改

FengR 1 개월 전
부모
커밋
6dfbb2eaee
1개의 변경된 파일15개의 추가작업 그리고 0개의 파일을 삭제
  1. 15 0
      app/Model/Article.php

+ 15 - 0
app/Model/Article.php

@@ -15,6 +15,21 @@ class Article extends Model
      */
     protected ?string $table = 'article';
 
+    /**
+     * 定义与分类的多对一关系
+     */
+    public function category()
+    {
+        return $this->belongsTo(Category::class, 'category_id', 'id');
+    }
+    /**
+     * 定义与分类的多对一关系
+     */
+    public function websiteCategory()
+    {
+        return $this->belongsTo(WebsiteCategory::class, 'category_id', 'id');
+    }
+
     /**
      * The attributes that are mass assignable.
      */