<?php

namespace App\Admin\Repositories;

use App\Models\BaseVideoCategory as Model;
use Dcat\Admin\Repositories\EloquentRepository;

class BaseVideoCategory extends EloquentRepository
{
    /**
     * Model.
     *
     * @var string
     */
    protected $eloquentClass = Model::class;

    // 调用模型方法
    public static function selectOptions(\Closure $closure = null,$root = false)
    {
        if (!$closure) {
            $closure = function ($query) {
                $query = $query->where('enabled', 1);
                $query =  $query->orderBy('order', 'desc')->orderBy('id', 'desc');
                return $query;
            };
        }

        $selectOptions =  Model::class::selectOptions($closure);
        if ($root == false) {
            unset($selectOptions[0]);
        }
        return $selectOptions;
    }
}
