<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;

use Illuminate\Database\Eloquent\Model;
use Spatie\EloquentSortable\Sortable;
use Spatie\EloquentSortable\SortableTrait;
use App\Traits\SortableTraitPinned;

class DistVideo extends Model
{
    use HasDateTimeFormatter;
    use SortableTraitPinned;

    protected $table = 'dist_video';

    // 可选：你可以在这里自定义排序配置
    public $sortable = [
        'order_column_name' => 'order',  // 排序字段
        'sort_when_creating' => true,    // 创建时自动排序
    ];

    protected $casts = [
        'created_at' => 'datetime:Y-m-d H:i:s',
        'updated_at' => 'datetime:Y-m-d H:i:s',
    ];

    /*
     * 分类一对多关联
     */
    public function distVideoCategory()
    {
        return $this->hasOne(DistVideoCategory::class,'id','category_id');
    }

}
