Downloading video to correct directory and displaying it on a chapter page.

This commit is contained in:
Krzysztof Płaczek
2022-11-17 08:24:17 +01:00
parent 21f61b0911
commit 2c62880282
4 changed files with 42 additions and 13 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -15,6 +16,8 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
* @property string $duration
* @property integer $course_id
* @property bool $sync_offline
* @property string $video_path
* @property string $directory_path
*/
class Chapter extends Model
{
@@ -35,4 +38,18 @@ class Chapter extends Model
{
return $this->belongsTo(Course::class);
}
protected function videoPath(): Attribute
{
return Attribute::make(
get: fn() => $this->directory_path . '/' . $this->id . '.' . $this->link . '.mp4'
);
}
protected function directoryPath(): Attribute
{
return Attribute::make(
get: fn() => $this->course_id . '.' . $this->course->link
);
}
}