belongsTo(Instrument::class); } public function auditionedEnsemble(): BelongsTo { return $this->belongsTo(AuditionedEnsemble::class); } protected function humanReadableFileSize(): Attribute { return Attribute::make( get: function () { $bytes = $this->file_size; if ($bytes === null) { return 'N/A'; } $units = ['B', 'KB', 'MB', 'GB', 'TB']; $bytes = max($bytes, 0); $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); $pow = min($pow, count($units) - 1); $bytes /= pow(1024, $pow); return round($bytes, 2).' '.$units[$pow]; } ); } }