Przeglądaj źródła

hasOne('App\Models\Tag', 'id', 'tag_id')

visuddhinanda 10 miesięcy temu
rodzic
commit
f6d3388f8b
1 zmienionych plików z 3 dodań i 3 usunięć
  1. 3 3
      api-v8/app/Models/TagMap.php

+ 3 - 3
api-v8/app/Models/TagMap.php

@@ -12,16 +12,16 @@ class TagMap extends Model
     protected $casts = [
         'id' => 'string'
     ];
-	protected $fillable = ['table_name' , 'anchor_id', 'tag_id'];
+    protected $fillable = ['table_name', 'anchor_id', 'tag_id'];
     use HasFactory;
 
-    public function progresschapter()
+    public function progressChapter()
     {
         return $this->belongsTo('App\Models\ProgressChapter', 'anchor_id', 'uid'); //参数一:需要关联的父表类名,前面必须加上命名空间  注意:参数二:子表关联父表的字段 参数三:父表关联子表的字段
     }
 
     public function tags()
     {
-        return $this->hasOne('App\Models\Tag', 'tag_id', 'id');
+        return $this->hasOne('App\Models\Tag', 'id', 'tag_id');
     }
 }