addMediaCollection('materials')->singleFile(); } public function courseClass(): BelongsTo { return $this->belongsTo(CourseClass::class); } protected function fileUrl(): Attribute { return Attribute::make( get: fn () => $this->getFirstMediaUrl('materials') ?: null, ); } protected function fileName(): Attribute { return Attribute::make( get: fn () => $this->getFirstMedia('materials')?->file_name, ); } }