<?php

namespace App;

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

/**
 * App\ApiAuth
 *
 * @property int $idapi_auth
 * @property string|null $nazev
 * @property string|null $user
 * @property string|null $password
 * @property int|null $vlozil
 * @property int|null $luser
 * @property string|null $vlozeny
 * @property string|null $zmena
 * @method static Builder|ApiAuth newModelQuery()
 * @method static Builder|ApiAuth newQuery()
 * @method static Builder|ApiAuth query()
 * @method static Builder|ApiAuth whereIdapiAuth($value)
 * @method static Builder|ApiAuth whereLuser($value)
 * @method static Builder|ApiAuth whereNazev($value)
 * @method static Builder|ApiAuth wherePassword($value)
 * @method static Builder|ApiAuth whereUser($value)
 * @method static Builder|ApiAuth whereVlozeny($value)
 * @method static Builder|ApiAuth whereVlozil($value)
 * @method static Builder|ApiAuth whereZmena($value)
 * @mixin Eloquent
 */
class ApiAuth extends Model
{
    protected $table = 'api_auth';
    protected $primaryKey = 'idapi_auth';
    protected $fillable = ['nazev','user','password','vlozil','luser'];
    public $timestamps = false;

    /**
     * @param string $user
     * @param string $pass
     * @return bool
     */
    public static function authUser(string $user, string $pass): bool
    {
       return DB::table('api_auth')->where([['user', '=',$user],['password','=',$pass]])->exists();
    }
}
