Browse Source

指定 uid 转换为 string

visuddhinanda@gmail.com 3 years ago
parent
commit
d1828bef8f
1 changed files with 8 additions and 0 deletions
  1. 8 0
      app/Models/ProgressChapter.php

+ 8 - 0
app/Models/ProgressChapter.php

@@ -11,6 +11,9 @@ class ProgressChapter extends Model
 	protected $fillable = ['book' , 'book', 'channel_id','lang'=>'en',
                             'all_trans','public','progress',
                             'title','created_at','updated_at'];
+      protected $casts = [
+            'uid' => 'string'
+        ];
     protected $primaryKey = 'uid';
     public function tagid()
     {
@@ -21,4 +24,9 @@ class ProgressChapter extends Model
     {
         return $this->belongsToMany('App\Models\Tag','tag_maps','anchor_id','tag_id');
     }
+
+    public function channel()
+    {
+        return $this->hasOne('App\Models\Channel', 'uid', 'channel_id'); //参数一:需要关联的子表类名,前面必须加上命名空间  参数二:子表关联父表的字段  参数三:父表关联子表的字段
+    }
 }