<?php


use Illuminate\Database\Eloquent\Model as Eloquent;

class User extends Eloquent
{

    protected $table   = 'users';
    protected $guarded = ['id'];

    public static function checkToken($token)
    {
        if($user = User::where('token','=',$token)
                /*->where('arrival_status','=',0)*/
                ->count() > 0) {
            return User::where('token','=',$token)->get();
        }

        return false;
    }

    public static function updateArrivalStatus($status, $id)
    {
        $user = User::find($id);
        $user->arrival_status = $status;

        if($user->save()) {
            return true;
        }

        return false;
    }

    public static function updateTransport($transport, $id)
    {
        $user = User::find($id);
        $user->transport = $transport;

        if($user->save()) {
            return true;
        }

        return false;
    }

    public static function checkEmail($email)
    {
        $count = User::where('email','=',$email)->count();
        if($count > 0) {
            return true;
        }

        return false;
    }
}