AdminMakeVideo.php
1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
namespace App\Models;
use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
class AdminMakeVideo extends Model
{
use HasDateTimeFormatter;
protected $table = 'admin_make_video';
protected $guarded = [''];
public function getVideoUrl()
{
if (Str::contains($this->video_url, '//')) {
return $this->video_url;
}
return Storage::disk('public')->url($this->video_url);
}
public function getThumbnailUrl()
{
if (Str::contains($this->thumbnail_url, '//')) {
return $this->thumbnail_url;
}
return Storage::disk('public')->url($this->thumbnail_url);
}
public function poem()
{
return $this->hasOne(OnePoem::class,'id','poem_id');
}
public function temp()
{
return $this->hasOne(VideoTemp::class,'id','temp_id');
}
public function getContentPosition($field = 'one_poem')
{
$component = $this->temp()->first()->components()->where('name','=',$field)->first();
return VideoTemp::POSITION_FFMPEG[$component->position];
}
}