<?php

namespace App\Services\Auth;
use App\Services\BaseService;
use App\Models\User;
use Illuminate\Auth\Events\Registered;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;

class RegisterService extends BaseService
{
    public function signup(array $data){
        $user = new User();
        $user->name         = $data['name'];
        $user->email       = $data['email'];
        $user->type       = 'user';
        $user->password       = Hash::make($data['password']);
        $user->save();
//        $user->sendEmailVerificationNotification();
        event(new Registered($user));
        $this->guard()->login($user);
    }

    protected function guard()
    {
        return Auth::guard();
    }
}
