56 lines
1.2 KiB
PHP
56 lines
1.2 KiB
PHP
<?php
|
|
|
|
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;
|
|
|
|
/**
|
|
* @property int $order
|
|
* @property string $link
|
|
* @property string $video_link
|
|
* @property integer $video_size
|
|
* @property string $title
|
|
* @property string $duration
|
|
* @property integer $course_id
|
|
* @property bool $sync_offline
|
|
* @property string $video_path
|
|
* @property string $directory_path
|
|
*/
|
|
class Chapter extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'order',
|
|
'link',
|
|
'video_link',
|
|
'video_size',
|
|
'title',
|
|
'duration',
|
|
'course_id',
|
|
'sync_offline',
|
|
];
|
|
|
|
public function course(): BelongsTo
|
|
{
|
|
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
|
|
);
|
|
}
|
|
}
|