Reading file size
This commit is contained in:
@@ -46,14 +46,14 @@ class Chapter extends Model
|
||||
protected function videoPath(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn() => $this->directory_path . '/' . $this->id . '.' . $this->link . '.mp4'
|
||||
get: fn() => $this->directory_path . '/' . $this->order . '.mp4'
|
||||
);
|
||||
}
|
||||
|
||||
protected function directoryPath(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn() => $this->course_id . '.' . $this->course->link
|
||||
get: fn() => public_path($this->course_id)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -63,4 +63,16 @@ class Chapter extends Model
|
||||
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;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user