Downloading files, calculating video size.
This commit is contained in:
@@ -8,6 +8,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property int $order
|
||||
* @property string $link
|
||||
* @property string $video_link
|
||||
@@ -18,6 +19,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
* @property bool $sync_offline
|
||||
* @property string $video_path
|
||||
* @property string $directory_path
|
||||
* @property Course $course
|
||||
*/
|
||||
class Chapter extends Model
|
||||
{
|
||||
@@ -34,6 +36,8 @@ class Chapter extends Model
|
||||
'sync_offline',
|
||||
];
|
||||
|
||||
protected $appends = ['video_path', 'directory_path'];
|
||||
|
||||
public function course(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Course::class);
|
||||
@@ -52,4 +56,11 @@ class Chapter extends Model
|
||||
get: fn() => $this->course_id . '.' . $this->course->link
|
||||
);
|
||||
}
|
||||
|
||||
protected function isVideoFile(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn() => is_file($this->video_path)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user