ProgressChapter.php 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\Model;
  5. class ProgressChapter extends Model
  6. {
  7. use HasFactory;
  8. protected $fillable = ['book' , 'book', 'channel_id','lang'=>'en',
  9. 'all_trans','public','progress',
  10. 'title','created_at','updated_at'];
  11. protected $casts = [
  12. 'uid' => 'string'
  13. ];
  14. protected $primaryKey = 'uid';
  15. public function tagid()
  16. {
  17. return $this->hasOne('App\Models\TagMap', 'anchor_id', 'uid'); //参数一:需要关联的子表类名,前面必须加上命名空间 参数二:子表关联父表的字段 参数三:父表关联子表的字段
  18. }
  19. public function tags()
  20. {
  21. return $this->belongsToMany('App\Models\Tag','tag_maps','anchor_id','tag_id');
  22. }
  23. public function channel()
  24. {
  25. return $this->hasOne('App\Models\Channel', 'uid', 'channel_id'); //参数一:需要关联的子表类名,前面必须加上命名空间 参数二:子表关联父表的字段 参数三:父表关联子表的字段
  26. }
  27. }