VideoTemp.php 1.47 KB
<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;

use Illuminate\Database\Eloquent\Model;

class VideoTemp extends Model
{
	use HasDateTimeFormatter;

	const POSITION_OPTIONS = [
        'topLeft'=>'顶部左对齐','topMiddle'=>'顶部居中','topRight'=>'顶部右对齐',
        'midLeft'=>'居中左对齐','midMiddle'=>'完全居中','midRight'=>'居中右对齐',
        'botLeft'=>'底部左对齐','botMiddle'=>'底部居中','botRight'=>'底部右对齐',
    ];

    const POSITION_FFMPEG = [
        'topLeft' => ['0', 'text_h+68'], 'topMiddle' => ['(w-text_w)/2', 'text_h+68'], 'topRight' => ['w-text_w', 'text_h+68'],
        'midLeft' => ['0', '(h-text_h)/2'], 'midMiddle' => ['(w-text_w)/2', '(h-text_h)/2'], 'midRight' => ['w-text_w', '(h-text_h)/2'],
        'botLeft' => ['0', 'h-text_h*2-68'], 'botMiddle' => ['(w-text_w)/2', 'h-text_h*2-68'], 'botRight' => ['w-text_w', 'h-text_h*2-68'],
    ];

    protected $table = 'video_temp';

    protected $guarded = [''];

    public function components()
    {
        return $this->hasMany('App\Models\Component','temp_id');
    }

    public function componentsTable()
    {
        return $this->hasMany('App\Models\Component', 'temp_id')
            ->select(['id', 'temp_id', 'name', 'position', 'font_size', 'text_color', 'text_bg_color', 'text_bg_box','opacity','fix_bounds']);
    }

    public function admin_make_video()
    {
        return $this->belongsTo(AdminMakeVideo::class,'temp_id');
    }
}