Downloading video to correct directory and displaying it on a chapter page.
This commit is contained in:
@@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user