AutraManager.php中的Laravel 5.2多表认证ErrorException(Laravel 5.2 Multi Table Authentication ErrorExceptio

编程入门 行业动态 更新时间:2024-10-28 07:25:13
AutraManager.php中的Laravel 5.2多表认证ErrorException(Laravel 5.2 Multi Table Authentication ErrorException in AuthManager.php)

我使用Laravel 5.2,我需要使用多表身份验证。 我从这个链接中读到任何人都可以通过示例解释Laravel 5.2 Multi Auth

我修改了config / auth.php

'guards' => [ 'user' =>[ 'driver' => 'session', 'provider' => 'user', ], 'admin' => [ 'driver' => 'session', 'provider' => 'admin', ], ], //User Providers 'providers' => [ 'user' => [ 'driver' => 'eloquent', 'model' => App\User::class, ], 'admin' => [ 'driver' => 'eloquent', 'model' => App\Admin::class, ] ], //Resetting Password 'passwords' => [ 'user' => [ 'provider' => 'user', 'email' => 'auth.emails.password', 'table' => 'password_resets', 'expire' => 60, ], 'admin' => [ 'provider' => 'admin', 'email' => 'auth.emails.password', 'table' => 'password_resets', 'expire' => 60, ], ],

这是登录控制器的一部分(post方法)

$admindata = array( 'email' => Input::get('email'), 'password' => Input::get('password') ); if (Auth::attempt($admindata)) { echo 'SUCCESS!'; } else { $admin = Auth::admin(); return Redirect::to('/b'); }

但我得到了这个错误

AuthManager.php第288行中的ErrorException:call_user_func_array()期望参数1是有效的回调,类'Illuminate \ Auth \ SessionGuard'没有方法'admin'

看起来错误在Auth::attempt() 。 如何解决这个错误?

I use Laravel 5.2 and I need to use multi table authentication. I read from this link Can anyone explain Laravel 5.2 Multi Auth with example

I modified config/auth.php

'guards' => [ 'user' =>[ 'driver' => 'session', 'provider' => 'user', ], 'admin' => [ 'driver' => 'session', 'provider' => 'admin', ], ], //User Providers 'providers' => [ 'user' => [ 'driver' => 'eloquent', 'model' => App\User::class, ], 'admin' => [ 'driver' => 'eloquent', 'model' => App\Admin::class, ] ], //Resetting Password 'passwords' => [ 'user' => [ 'provider' => 'user', 'email' => 'auth.emails.password', 'table' => 'password_resets', 'expire' => 60, ], 'admin' => [ 'provider' => 'admin', 'email' => 'auth.emails.password', 'table' => 'password_resets', 'expire' => 60, ], ],

Here is part of the controller for login (post method)

$admindata = array( 'email' => Input::get('email'), 'password' => Input::get('password') ); if (Auth::attempt($admindata)) { echo 'SUCCESS!'; } else { $admin = Auth::admin(); return Redirect::to('/b'); }

But I got this error

ErrorException in AuthManager.php line 288: call_user_func_array() expects parameter 1 to be a valid callback, class 'Illuminate\Auth\SessionGuard' does not have a method 'admin'

It looks like the error is on Auth::attempt(). How to solve this error?

最满意答案

我相信错误不是attempt方法,而是在这里:

$admin = Auth::admin();

你尝试在这里运行admin方法,显然在Illuminate\Auth\SessionGuard类中没有这样的方法。

I believe the error is not in attempt method but here:

$admin = Auth::admin();

You try to run here admin method and obviously there is no such method in Illuminate\Auth\SessionGuard class.

更多推荐

Auth,'admin',Laravel,电脑培训,计算机培训,IT培训"/> <meta name=&quo

本文发布于:2023-08-02 13:27:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1376886.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Laravel   AutraManager   php   ErrorException   Authentication

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!