默认情况下,只能为一个表设置Laravel 4身份验证功能。
现在我有一个需要进行身份验证的管理表。该表与用户表分开。没有安装Sentry有没有办法做到这一点?
我尝试在app / config / auth.php中使用数组设置更多模型和表格,但似乎Laravel不支持数组。
编辑,从回答/问题移动代码:
实际上没有,我尝试过使用类似的东西:
if($res = DB::select('select * from admin where email = ? and password = ?', array(Input::get('email'), Input::get('password')))) {
echo 'success';
//return Response::json(['admin' => Auth::admin()->toArray()], 202);
}
else {
echo 'failed';
//return Response::json(['flash' => 'Authentication failed'], 401);
}
in the method store() of my controller, but failed. Can anyone help me with this?
答案 0 :(得分:0)
从未尝试过,但只是一个想法:如果你的管理员表有一个Admin
模型,并且有一个控制器(管理员控制器)来访问这个模型,你可以设置auth.model
像
function __construct()
{
Config::set('auth.model', 'Admin');
}
但是,不确定这是否是你想要的,这是正确的方法。
更新:这看起来像an answer,您可能正在寻找。