Parcourir la source

add owner progressChapters

visuddhinanda il y a 10 mois
Parent
commit
623a51f81e
1 fichiers modifiés avec 14 ajouts et 1 suppressions
  1. 14 1
      api-v8/app/Models/Channel.php

+ 14 - 1
api-v8/app/Models/Channel.php

@@ -8,11 +8,24 @@ use Illuminate\Database\Eloquent\Model;
 class Channel extends Model
 class Channel extends Model
 {
 {
     use HasFactory;
     use HasFactory;
-    protected $fillable = ['name','summary','type','lang','status','updated_at','created_at'];
+    protected $fillable = ['name', 'summary', 'type', 'lang', 'status', 'updated_at', 'created_at'];
 
 
     protected $primaryKey = 'uid';
     protected $primaryKey = 'uid';
     protected $casts = [
     protected $casts = [
         'uid' => 'string'
         'uid' => 'string'
     ];
     ];
     public  $incrementing = false;
     public  $incrementing = false;
+
+    /**
+     * 反向关联到 ProgressChapter
+     */
+    public function progressChapters()
+    {
+        return $this->hasMany(ProgressChapter::class, 'channel_id', 'uid');
+    }
+
+    public function owner()
+    {
+        return $this->belongsTo(UserInfo::class, 'owner_uid', 'userid');
+    }
 }
 }