I'm trying to only allow certain ip addresses to access the register route, but I'm getting Type error:
Argument 1 passed to
App\Http\Controllers\Auth\AuthController::showRegistrationForm() must
be an instance of Illuminate\Http\Request, none given, called in
directory\vendor\laravel\framework\src\Illuminate\Foundation\Auth\RegistersUsers.php
on line 19
Here is my showRegistrationForm
method in AuthController
:
public function showRegistrationForm(Request $request) {
$ip = $request->ip();
if ($ip == "148.124.0.1") {
return redirect("register");
} else {
return redirect("home");
}
}
Does anyone know how I would accomplish this?
Best Answer
Instead checking in controller please check this way
Code
then add the new middleware class in the $
middleware
property of yourapp/Http/Kernel.php
class.then apply middelware to routes
I hope this helps!