<?php

namespace App\Modules\Book\Services;
use App\Modules\Book\Models\BookDomain;


class BookDomainService {
    /**
     * 获取可用域名
     */
    public static function getEnableDomain(){
        return BookDomain::where('is_enabled',1)->select('id','domain')->get();
    }

    /**
     * 新增域名 ['domain'=>'abc.com','is_enabled'=>1]
     * @param $data
     * @return mixed
     */
    public static function addDomain($data){
        return BookDomain::create($data);
    }


    /**
     * 图书域名是否存在
     * @param $doamin
     * @return mixed
     */
    public static function  isExists($doamin){
        return BookDomain::where('is_enabled',1)->where('domain',$doamin)->count();
    }
}
