belongsTo(Course::class); } protected function videoPath(): Attribute { return Attribute::make( get: fn() => $this->directory_path . '/' . $this->order . '.mp4' ); } protected function directoryPath(): Attribute { return Attribute::make( get: fn() => public_path($this->course_id) ); } protected function isVideoFile(): Attribute { return Attribute::make( get: fn() => is_file($this->video_path) ); } public function videoSizeHuman(): Attribute { return Attribute::make( get: function () { $base = log($this->video_size) / log(1024); $suffix = ["", "k", "M", "G", "T"][floor($base)]; return round(pow(1024, $base - floor($base)), 2) . $suffix; }, ); } }