<?php

namespace App\Modules\ShareFree\Models;

use App\Modules\Book\Services\BookConfigService;
use Illuminate\Database\Eloquent\Model;

class ShareUsers extends Model
{
    protected $table = 'share_users';
    protected $fillable = ['id', 'uid', 'bid', 'distribution_channel_id', 'cid','book_name', 'status'];

    public static function addShareUsers($data)
    {
        if(!isset($data['uid'])||!isset($data['bid'])) {
            return false;
        }
        $rec = self::where('uid',$data['uid'])->where('bid',$data['bid'])->first();

        if(!$rec) {
            return self::create($data);
        }
        return $rec;
    }
}
