<?php

namespace App\Modules\Cpa\Models;

use Illuminate\Database\Eloquent\Model;

class AdvertiseUserQueque extends Model
{
    protected $table = 'advertise_user_queue';
    protected $fillable = ['id', 'ad_user_id', 'uid', 'bid', 'advertise_id', 'add_time','status'];

    public static function addToQueue($params){
        $res = self::where('uid',$params['uid'])
            //->where('status',1)
            ->first();
        if(!$res) {
            return self::updateOrCreate($params);
        }
        return false;
    }

    public static function getUserAdvertiseSubscribe($uid,$bid){
        return self::where('uid',$uid)->where('bid',$bid)->where('status',1)->first();
    }

    public static function getUserAdvertise($uid) {
        return self::where('uid',$uid)->where('status',1)->first();
    }
}
