<?php
namespace App\Libraries;

use App\Models\UserModel;

class Userdata
{
    public $data;

    public function GetUser($id_auth){
        $db = db_connect();
        $userModel = model('UserModela', true, $db);
        $level = $userModel->getLevel($id_auth);
        if ($level == 'user_office')
        {
            $user = auth()->user();
            $tmodel = model('Usermodelc', true, $db);
            $this->data = $tmodel->where('email',$user->getEmail())->first();
        }

        if ($level == 'admin')
        {
            $user = auth()->user();
            $tmodel = model('Usermodelc', true, $db);
            $this->data = $tmodel->where('id_auth',auth()->id())->first();
        }

        if ($level == 'user_customer')
        {
            $user = auth()->user();
            $tmodel = model('AgenModel', true, $db);
            $this->data = $tmodel->where('sold_id',$user->getEmail())->first();
        }
    }
}
?>