我需要为电子邮件验证创建自定义登录身份验证,我会发布一些代码段来让您了解问题:
但是,我收到以下 Class App \ Http \ Controllers \ Auth \ Request不存在
堆栈溢出说我需要更多的文本,因为它主要是代码,我希望这里的expert足以将其提升。
login.blade - auth附带的默认值,只是调整了littleyl
<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',
]);
}
}
答案 0 :(得分:4)
您没有使用所需的命名空间,请尝试在控制器中使用以下命令:
use Illuminate\Http\Request;
由于您的脚本尝试从当前命名空间加载Request类App\Http\Controllers\Auth
答案 1 :(得分:1)
尝试在控制器中添加此行
addTestDevice(XXX)
答案 2 :(得分:0)
在您的命名空间中,使用以下代码或在您的命名空间中包含以下错误请求:
use Illuminate\Http\Request;