There was a problem while doing authentication operations on the laravel admin.
FatalThrowableError (E_ERROR)
Function name must be a string
Admin Controlller:
class AdminController extends Controller
{
public function __construct()
{
$this->middleware('auth:admin');
}
public function index(){
return view('comparadm.dashboard');
}}
AdminLogin Controlller:
class AdminLoginController extends Controller
{
public function __construct()
{
$this->middleware('guest:admin');
}
public function showLoginForm()
{
return view('auth.admin-login');
}
public function login(Request $request){
$this->validate($request,[
'email'=>'required|email',
'password'=>'required|min:6'
]);
if(Auth::guard('admin')->attempt(['email'=>$request->email,'password'=>$request->password],$request->remember))
{
return redirect()->intended(route('admin.dashboard'));
}
return redirect()->back()->withInput($request->only('email','remember'));
}}
Routes:
Auth::routes();
Route::prefix('admin')->group(function() {
Route::get('/login', 'AuthAdminLoginController@showLoginForm')->name('admin.login');
Route::post('/login', 'AuthAdminLoginController@login')->name('admin.login.submit');
Route::get('/', 'AdminController@index')->name('admin.dashboard');});
Advertisement
Answer
The answer might not be relevant to this specific question though, but at least may be able to point someone in the right direction. I had the same problem, but I later found out that I messed up RedirectIfAuthenticated.php located within the ‘AppHttpMiddlewareRedirectIfAuthenticated.php’. The problem was that I commented the handle function which is shown below
public function handle($request, Closure $next, $guard = null) {
if (Auth::guard($guard)->check()) {
return redirect('/home');
}
return $next($request);
}
It worked like magic after I removed the comments.