ProgressChapter.php 801 B

123456789101112131415161718192021222324
  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 $primaryKey = 'uid';
  12. public function tagid()
  13. {
  14. return $this->hasOne('App\Models\TagMap', 'anchor_id', 'uid'); //参数一:需要关联的子表类名,前面必须加上命名空间 参数二:子表关联父表的字段 参数三:父表关联子表的字段
  15. }
  16. public function tags()
  17. {
  18. return $this->belongsToMany('App\Models\Tag','tag_maps','anchor_id','tag_id');
  19. }
  20. }