<?php
namespace App\Libraries;

use App\Models\UserModel;

class Userdata
{
    public $data;

    public function GetUser(){
        $db = db_connect();
        $user = auth()->user();
        $level = $user->getGroups()[0];
        if ($level == 'admin')
        {
            $UserModel = model('Usermodeladmin', true, $db);
            $builder = $UserModel->builder("vadmin");
            $this->data = $builder->where('email',$user->getEmail())->get()->getRow();
        }elseif ($level == 'operator')
        {
            $UserModel = model('Usermodeloperator', true, $db);
            $builder = $UserModel->builder("voperator");
            $this->data = $builder->where('email',$user->getEmail())->get()->getRow();
        }elseif ($level == 'kolektor')
        {
            $UserModel = model('Usermodelkolektor', true, $db);
            $builder = $UserModel->builder("vkolektor");
            $this->data = $builder->where('email',$user->getEmail())->get()->getRow();
        }
    }
}
?>