Parcourir la source

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

FengR il y a 1 mois
Parent
commit
6dfbb2eaee
1 fichiers modifiés avec 15 ajouts et 0 suppressions
  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.
      */