<?php

namespace App\Distributor\Repositories;

use App\Models\SitePages as Model;
use App\Traits\DistCommonTrait;
use Dcat\Admin\Repositories\EloquentRepository;

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

    /*
     * 查找最新的N个文章
     */
    public static function selectOptionsNew($limit=30)
    {
        return Model::where('dist_id', getDistributorId())->where('status', 1)->orderBy('created_at', 'desc')->limit($limit)->pluck('title', 'id');
    }

    /*
 * 获取一个标签
 */
    public static function getOneById($id)
    {
        return Model::where('id', $id)->where('dist_id', getDistributorId())->first();
    }

}
