Added helper file, replaced size file for human version as a helper method, next prev buttons for chapters.
This commit is contained in:
@@ -36,13 +36,20 @@ class Chapter extends Model
|
||||
'sync_offline',
|
||||
];
|
||||
|
||||
protected $appends = ['video_path', 'directory_path'];
|
||||
protected $appends = ['video_path', 'directory_path', 'video_url'];
|
||||
|
||||
public function course(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Course::class);
|
||||
}
|
||||
|
||||
protected function videoUrl(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn() => url($this->course_id . '/' . $this->order . '.mp4')
|
||||
);
|
||||
}
|
||||
|
||||
protected function videoPath(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
@@ -68,9 +75,7 @@ class Chapter extends Model
|
||||
{
|
||||
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;
|
||||
return formatFileSize($this->video_size);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user