<?php
/**
 * Created by PhpStorm.
 * User: tandunzhao
 * Date: 2017/11/17
 * Time: 下午4:44
 */

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




class UserShelfBooksService
{


    /**
     * 根据uid获取书架
     */
    static function getUserShelfBooksListByUid($uid,$page_size=15,$is_all=false)
    {
        return UserShelfBooks::getUserShelfBooksListByUid($uid,$page_size,$is_all);
    
    }

    /**
     * 根据uid,bid获取书架
     * 用于判断用户是添加本书
     * @param $uid
     * @param $bid
     * @return mixed
     */
    static function getUserShelfBooksListByUidAndBid($uid,$bid){
        return UserShelfBooks::getUserShelfBooksListByUidAndBid($uid,$bid);
    }

    /**
     * 获取书架图书信息
     * @param $id
     * @return model
     */
    static function getShelfById($id){
        return UserShelfBooks::getShelfById($id);
    }


    /**
     * 添加书架
     * @param $data
     * @return mixed
     */
    static function create($data){
        return UserShelfBooks::create($data);
    }

    /**
     * 删除书架
     * @param $uid
     * @param $bid
     * @return mixed
     */
    static function del($uid,$bid){
        return UserShelfBooks::where('uid',$uid)->where('bid',$bid)->delete();
    }
}