diff --git a/app/Http/Controllers/Auth/RegisteredUserController.php b/app/Http/Controllers/Auth/RegisteredUserController.php index cace061..7a3673b 100644 --- a/app/Http/Controllers/Auth/RegisteredUserController.php +++ b/app/Http/Controllers/Auth/RegisteredUserController.php @@ -18,6 +18,13 @@ class RegisteredUserController extends Controller { + /** + * Display the registration view. + */ + public function create(): View + { + return view('auth.register'); + } /** * Handle an incoming registration request. * diff --git a/app/Livewire/Register.php b/app/Livewire/Register.php index 75970c3..c57241d 100644 --- a/app/Livewire/Register.php +++ b/app/Livewire/Register.php @@ -12,14 +12,13 @@ use Illuminate\Foundation\Application; use Illuminate\Http\RedirectResponse; use Illuminate\Routing\Redirector; +use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Notification; use Illuminate\View\View; -use Livewire\Attributes\Validate; use Livewire\Component; class Register extends Component { - public $name; public $email; public $phone; @@ -27,9 +26,24 @@ class Register extends Component public $password; public $password_confirmation; - public function register(): Application|Redirector|\Illuminate\Contracts\Foundation\Application|RedirectResponse + public function mount(): void { + $this->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, @@ -38,8 +52,6 @@ public function register(): Application|Redirector|\Illuminate\Contracts\Foundat 'password' => Hash::make($this->password), ]; - dd($user_data_array); - $this->validate([ 'name' => ['required', 'string', 'max:255'], 'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:' . User::class], diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php index 644e454..5e50003 100644 --- a/resources/views/auth/register.blade.php +++ b/resources/views/auth/register.blade.php @@ -1,7 +1,6 @@ -