帮助我理解并解决这些错误。
错误:
Symfony\Component\Debug\Exception\FatalThrowableError(E\u RECOVERABLE\u ERROR)类型错误:传递给App\Http\Controllers\Auth\LoginController::authenticated()的参数1必须是App\Http\Controllers\Auth\Request的实例,给定的light\Http\Request的实例,在第104行的C:\proj\easywash\vendor\laravel\framework\src\illumb\Foundation\Auth\AuthenticatesUsers.php中调用
登录控制器:
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
use App\Http\Requests;
use Auth;
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest', ['except'=> ['logout','userLogout']]);
}
public function authenticated(Request $request, $user)
{
if (!$user->verified) {
auth()->logout();
return back()->with('warning', 'You need to confirm your account. We have sent you an activation code, please check your email.');
}
return redirect()->intended($this->redirectPath());
}
public function userLogout()
{
Auth::guard('web')->logout();
return redirect('/home');
}
}
寄存器控制器:
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use App\Mail\VerifyMail;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
use App\VerifyUser;
use Auth;
use DB;
use Mail;
use Illuminate\Http\Request;
class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/
use RegistersUsers;
/**
* Where to redirect users after registration.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\User
*/
protected function create(array $data)
{
$user = User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
$verifyUser = VerifyUser::create([
'user_id' => $user->id,
'token' => str_random(40)
]);
Mail::to($user->email)->send(new VerifyMail($user));
return $user;
}
public function verifyUser($token)
{
$verifyUser = VerifyUser::where('token', $token)->first();
if(isset($verifyUser) ){
$user = $verifyUser->user;
if(!$user->verified) {
$verifyUser->user->verified = 1;
$verifyUser->user->save();
$status = "Your e-mail is verified. You can now login.";
}else{
$status = "Your e-mail is already verified. You can now login.";
}
}else{
return redirect('/login')->with('warning', "Sorry your email cannot be identified.");
}
return redirect('/login')->with('status', $status);
}
protected function registered(Request $request, $user)
{
$this->guard()->logout();
return redirect('/login')->with('status', 'We sent you an activation code. Check your email and click on the link to verify.');
}
}
目录-
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);`enter code here`
}
用户模型上的控件x代码和控件v
所以使用终端php工匠路由:列表
我也有和你一样的问题,我用这个答案解决了这个问题。
在LoginController中更改您的使用
语句:
use Illuminate\Http\Request;
// And try to comment out the next line
// use App\Http\Requests;
您正在从
身份验证用户
特性中重写此方法,该特性接收一个照明\Http\请求
,而不是一个应用\Http\控制器\Auth\请求
当我将数据发送到MySQL数据库时,我在上遇到了这个错误 此错误: 函数App\Http\Controllers\Auth\LoginController::authenticated()的参数太少,在C:\xampp\htdocs\codecrowne\vendor\laravel\framework\src\light\Foundation\Auth\AuthenticatesUsers.ph
我正在尝试发送验证电子邮件,这是给我的错误代码 它给了我以下错误: 传递给App\Http\Controllers\Auth\RegisterController::registed()的参数1必须是App\Http\Controllers\Auth\Request的实例,给定的照亮\Http\Request的实例,在/home/bassel/book\u generation/vendor/la
我想在login()返回类型中使用authenticated()。我想尝试,当用户试图通过他们的phn_号码登录时,他们可以登录,并且还可以检查中间件/用户_角色。我在Authenticated()上编写的这部分代码。所以我的计划是当我登录时,login()也将通过authenticated()返回。 因此,它返回给函数App\Http\Controllers\Auth\LoginControll
我正在尝试在我的注册控制器中注册多用户,并使用以下代码进行检查。但它告诉我一个错误: 方法App\Http\Controllers\Auth\RegisterController::validator不存在。
传递给Illumate\Auth\EloquentUserProvider的参数1::validateCreentials()必须是Illumate\合同\Auth\身份验证的实例,应用程序\模型\用户给定的实例,在D:\xampp\htdocs\后端\电子商务\供应商\laravel\框架\src\Illumate\Auth\SessionG中uard.php第384行----我有这个问题请帮我
前端: 控制器: 我得到这个错误: 类型错误:传递给Gloudemans\Shoppingcart\Cart::search()的参数1必须是闭包的实例,给定数组,在C:\xampp\htdocs\ecomerce\vendor\laravel\framework\src\Illumbite\Support\Facades\Facade中调用。php在线221