<?php

namespace App\Classes;

use App\Models\User;
use Illuminate\Support\Facades\DB;


class AuthUser
{
    public function check($email,$name)
    {

            $ApiUser =  User::where('email', $email)->first();

            if ($ApiUser == null) {
                $ApiUser = User::create([
                    'name' => $name,
                    'email' => $email,
                    'password' => bcrypt('123456info@yefix.com'),
                ]);

                DB::table('user_details')->insert([
                    'user_id' => $ApiUser->id,
                    'company' => 'Api User',
                    'message' => 'Api User',
                    'token_admin' => 'no',
                    'user_status' => 'active'
                ]);
            }

        return $ApiUser;
    }

    
}
