Downloading files, calculating video size.

This commit is contained in:
Krzysztof Płaczek
2022-11-17 11:38:20 +01:00
parent 2c62880282
commit 55c104629f
9 changed files with 77 additions and 23 deletions

View File

@@ -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)
);
}
}