Channel.php 705 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\Model;
  5. class Channel extends Model
  6. {
  7. use HasFactory;
  8. protected $fillable = ['name', 'summary', 'type', 'lang', 'status', 'updated_at', 'created_at'];
  9. protected $primaryKey = 'uid';
  10. protected $casts = [
  11. 'uid' => 'string'
  12. ];
  13. public $incrementing = false;
  14. /**
  15. * 反向关联到 ProgressChapter
  16. */
  17. public function progressChapters()
  18. {
  19. return $this->hasMany(ProgressChapter::class, 'channel_id', 'uid');
  20. }
  21. public function owner()
  22. {
  23. return $this->belongsTo(UserInfo::class, 'owner_uid', 'userid');
  24. }
  25. }