我正在尝试在我的网站上制作多个auth;我希望将日志视为用户,另一个视图作为客户端登录。我有一个用户表,并且我创建了一个带代码的客户端表,而不是邮件和mtpass,而不是密码。
clientlogincontroller
<?php
namespace AppHttpControllers;
use AppHttpControllersController as CltController;
use IlluminateFoundationAuthAuthenticatesUsers;
use IlluminateHttpRequest;
use IlluminateSupportFacadesAuth;
class ClientLoginController extends CltController
{
use AuthenticatesUsers;
public function __construct()
{
$this->middleware('auth:client');
}
public function login()
{
return view('client.auth.login');
}
public function showClientLoginForm()
{
return view('auth.loginClient', ['url' => 'client']);
}
public function clientLogin(Request $request)
{
$this->validate($request, [
'Code' => 'required|email',
'Mtpass' => 'required|min:4'
]);
if (Auth::guard('client')->attempt(['Code' => $request->Code, 'Mtpass' => $request->Mtpass], $request->get('remember'))) {
return redirect()->intended('/main');
}
return back()->withInput($request->only('Code', 'remember'));
}
}
logincontroller
<?php
namespace AppHttpControllersAuth;
use AppHttpControllersController;
use IlluminateFoundationAuthAuthenticatesUsers;
use IlluminateHttpRequest;
use IlluminateSupportFacadesAuth;
class LoginController extends Controller
{
use AuthenticatesUsers;
public function __construct()
{
$this->middleware('guest')->except('logout');
$this->middleware('guest:client')->except('logout');
}
public function showClientLoginForm()
{
return view('auth.loginClient', ['url' => 'client']);
}
public function clientLogin(Request $request)
{
$this->validate($request, [
'Code' => 'required|email',
'Mtpass' => 'required|min:4'
]);
if (Auth::guard('client')->attempt(['Code' => $request->Code, 'Mtpass' => $request->Mtpass], $request->get('remember'))) {
return redirect()->intended('/main');
}
return back()->withInput($request->only('Code', 'remember'));
}
protected function redirectTo()
{
$role_id = auth()->user()->role_id;
if (auth()->check()) {
switch ($role_id) {
case 1:
return 'admin/profil';
case 2:
return 'client/profil';
case 3:
return 'agent/profil';
}
}
return '/main';
}
}
我无法弄清楚如何修复以下错误。
无法声明类应用程序 http controllers clientlogincontroller,因为该名称已经在使用
有人可以帮助我解决并了解正在发生的事情吗?谢谢大家!
我有这个问题,
无法通过作曲家转储 - autoload
解决然后使用此解决方案
https://stackoverflow.com/a/64385832/308578