<?php
/**
 * Created by PhpStorm.
 * User: hp
 * Date: 2017/11/21
 * Time: 8:59
 */

namespace App\Modules\Channel\Models;

use DB;
use Illuminate\Database\Eloquent\Model;

class ChannelBookSell extends Model
{
    protected $table = 'channel_book_sell_stats';
    protected $fillable = ['id', 'plaform', 'zsy_bid', 'book_name', 'plaform_code', 'amount', 'sub_num', 'date', 'month',
        'is_checked', 'is_pushed', 'bill_type', 'created_at', 'updated_at'];


    static function  addInfo($data){
        return self::create($data);
    }

    /**
     * 根据id查找
     * @param $id
     * @return mixed
     */
    static function getById($id)
    {
        return self::where('id', $id)->first();
    }

    /**
     * 根据名称查找
     * @param $name
     * @return mixed
     */
    static function getByName($book_name)
    {
        return self::where('book_name', $book_name)->get();
    }

    /**
     * 根据code查找
     * @param $code
     * @return mixed
     */
    static function getByCode($code)
    {
        return self::where('code', $code)->get();
    }

    /**
     * 获取列表
     * @return mixed
     */
    static function getList()
    {
        return self::paginate();
    }

    static function updateStatus($id,$params=[])
    {
        if ($params){
            return self::where('id',$id)->update($params);
        }
    }

}