简体   繁体   中英

Laravel 5.4 Class App\Http\Controllers\Auth\Request does not exist

I need to create a custom login auth for email verification, I will post some snippets to give you an idea of the problem:

But, i receive the following Class App\\Http\\Controllers\\Auth\\Request does not exist

Stack overflow is saying i need more text as it is mostly code, i hope this excpert here will be enough to bump it up.

The login.blade - default that comes with auth, just tweaked slightyl

<form class="form-horizontal" method="POST" action="{{ route('loginc') }}">
                    {{ csrf_field() }}

                    <div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
                        <label for="email" class="col-md-4 control-label">E-Mail Address</label>

                        <div class="col-md-6">
                            <input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required autofocus>

                            @if ($errors->has('email'))
                                <span class="help-block">
                                    <strong>{{ $errors->first('email') }}</strong>
                                </span>
                            @endif
                        </div>
                    </div>

                    <div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
                        <label for="password" class="col-md-4 control-label">Password</label>

                        <div class="col-md-6">
                            <input id="password" type="password" class="form-control" name="password" required>

                            @if ($errors->has('password'))
                                <span class="help-block">
                                    <strong>{{ $errors->first('password') }}</strong>
                                </span>
                            @endif
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-md-6 col-md-offset-4">
                            <div class="checkbox">
                                <label>
                                    <input type="checkbox" name="remember" {{ old('remember') ? 'checked' : '' }}> Remember Me
                                </label>
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-md-8 col-md-offset-4">
                            <button type="submit" class="btn btn-primary">
                                Login
                            </button>

                            <a class="btn btn-link" href="{{ route('password.request') }}">
                                Forgot Your Password?
                            </a>
                        </div>
                    </div>
                </form>

loginController.php

namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Auth\Request;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;

class LoginControllerCustom extends Controller
{
use AuthenticatesUsers;
public function login(Request $request)
{

        return 'boo';
        $this->validateLogin($request);
 {

protected function validateLogin(Request $request)
{
    $this->validate($request, [
        $this->username() => 'required|string|max:150',
        'password' => 'required|string|max:150',
    ]);
}
}

You are not using the required namespace, try to use the following in your controller:

use Illuminate\Http\Request;

You are getting the error due to the fact that your script tries to load the Request class from the current namespace App\\Http\\Controllers\\Auth

尝试在您的控制器中添加这一行

use Illuminate\Http\Request;

在您的命名空间中,使用以下代码或包含在您的命名空间中,以便找到错误请求:

use Illuminate\Http\Request;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM