From af3fe62c318e3de73faf9f0143f97213fe26fe5d Mon Sep 17 00:00:00 2001 From: raccoon254 Date: Mon, 24 Jun 2024 11:44:07 +0300 Subject: [PATCH] Deleted register component --- app/Livewire/Register.php | 90 --------------------------------------- 1 file changed, 90 deletions(-) delete mode 100644 app/Livewire/Register.php diff --git a/app/Livewire/Register.php b/app/Livewire/Register.php deleted file mode 100644 index c57241d..0000000 --- a/app/Livewire/Register.php +++ /dev/null @@ -1,90 +0,0 @@ -location = $this->getUserCountry(); - } - - public function getUserCountry(): string - { - try { - $response = Http::get('https://ipinfo.io/json'); - $data = $response->json(); - return $data['country'] ?? 'Unknown'; - } catch (\Exception $e) { - return 'Unknown'; - } - } - - public function register(): Application|Redirector|\Illuminate\Contracts\Foundation\Application|RedirectResponse - { - $user_data_array = [ - 'name' => $this->name, - 'email' => $this->email, - 'phone' => $this->phone, - 'location' => $this->location, - 'password' => Hash::make($this->password), - ]; - - $this->validate([ - 'name' => ['required', 'string', 'max:255'], - 'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:' . User::class], - 'phone' => ['required', 'string', 'max:255', 'min:8', 'unique:' . User::class], - 'location' => ['required', 'string', 'max:255', 'min:3'], - 'password' => ['required', 'confirmed', Rules\Password::defaults()], - ]); - - $user = User::create([ - 'name' => $this->name, - 'email' => $this->email, - 'phone' => $this->phone, - 'location' => $this->location, - 'password' => Hash::make($this->password), - ]); - - event(new Registered($user)); - - Auth::login($user); - - // Send notification to the new user - $user->notify(new UserWelcome($user)); - - // Send notification to all writers - $writers = User::where('role', 'writer')->get(); - Notification::send($writers, new NewUserJoined($user)); - - return redirect(route('dashboard')); - } - - public function render(): View - { - return view('auth.register') - ->layout('layouts.guest'); - } -}