first commit
This commit is contained in:
80
app/Models/Video.php
Normal file
80
app/Models/Video.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Str;
|
||||
|
||||
/**
|
||||
* Class Video
|
||||
*
|
||||
* @property int $id
|
||||
* @property string|null $external_id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Collection|VideoRender[] $video_renders
|
||||
*/
|
||||
class Video extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'videos';
|
||||
|
||||
protected $casts = [
|
||||
'width' => 'int',
|
||||
'height' => 'int',
|
||||
'payload' => 'object',
|
||||
'render_settings' => 'object',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'external_id',
|
||||
'content_type',
|
||||
'width',
|
||||
'height',
|
||||
'aspect_ratio',
|
||||
'payload',
|
||||
'render_settings',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'id',
|
||||
];
|
||||
|
||||
public function video_renders()
|
||||
{
|
||||
return $this->hasMany(VideoRender::class)->orderBy('id', 'DESC');
|
||||
}
|
||||
|
||||
public function video_captions()
|
||||
{
|
||||
return $this->hasMany(VideoCaption::class)->orderBy('time', 'ASC');
|
||||
}
|
||||
|
||||
public function video_elements()
|
||||
{
|
||||
return $this->hasMany(VideoElement::class)->orderBy('time', 'ASC');
|
||||
}
|
||||
|
||||
public function latest_render()
|
||||
{
|
||||
return $this->hasOne(VideoRender::class)->latest();
|
||||
}
|
||||
|
||||
/**
|
||||
* The "booted" method of the model.
|
||||
*/
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function ($model) {
|
||||
$model->uuid = $model->uuid ?? (string) Str::uuid();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user