<?php

namespace App\Distributor\Repositories;

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

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

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

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

}
