*/ protected $fillable = [ 'room_name', 'room_auto', 'room_owner', 'room_des', 'room_top', 'room_title', 'room_keep', 'room_time', 'room_tt', 'room_html', 'room_exp', 'build_time', 'permit_level', 'door_open', 'announcement', ]; /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'room_time' => 'datetime', 'build_time' => 'datetime', 'room_keep' => 'boolean', 'room_tt' => 'boolean', 'room_html' => 'boolean', 'door_open' => 'boolean', ]; } // ---- 兼容新版逻辑和 Blade 视图的访问器 ---- public function getNameAttribute(): string { return $this->room_name ?? ''; } public function getDescriptionAttribute(): string { return $this->room_des ?? ''; } public function getMasterAttribute(): string { return $this->room_owner ?? ''; } public function getIsSystemAttribute(): bool { return (bool) $this->room_keep; } // 同样可为主讲人关联提供便捷方法 public function masterUser() { return $this->belongsTo(User::class, 'room_owner', 'username'); } }