<?php

namespace App\Models;
use Illuminate\Support\Facades\DB;
class Wagent extends BaseModel
{
	protected $table = 'wagent';
	public $timestamps = false;

    function wagentlist($list = 10, $page, $where = '')
    {
    	if (is_array ($where) && count ($where) > 0) { 
    		$data = $this->select($this->table.'.*')->orderby($this->table.'.id','desc')->where($where)->paginate ($list); 
    	}else{
    		$data = $this->select($this->table.'.*')->orderby($this->table.'.id','desc')->paginate ($list); 
    	}
    	for ($i=0; $i < count($data); $i++) { 
    		$data[$i]->auth_expire = date("Y-m-d",$data[$i]->auth_expire);
    	}
    	return $data->toArray (); 
    }

    //唯一性
    function onlywagent($name,$pre){
    	$res = $this->where ('agent_name', $name)->orwhere('agent_pre',$pre)->first ();
    	if ($res) {
            return 2; //唯一性
        }
        return 1;
    }

}