问题在于它给出了一个错误。
未定义的属性:Illuminate \ Auth \ SessionGuard :: $ confirmed
这是我的代码:
if (Auth::guard('pharmacy')->confirmed == 1) {
if (Auth::guard('pharmacy')->status == 'Approved') {
return redirect()->intended(route('pharmacy.dashboard'));
}
}
答案 0 :(得分:0)
您应该改为这样做:
if (Auth::guard('pharmacy')->attempt(['email' => $email, 'password' => $password])) {
if (Auth::user()->confirmed == 1 && Auth::user()->status == 'Approved') {
return redirect()->intended(route('pharmacy.dashboard'));
}
//You might want to do something else here for those that fail either the confirmed or approved check.
}
首先,您应该针对pharmacy
保护实例对用户进行身份验证。只有在用户通过身份验证后,您才可以访问他/她的attributes
...在您的情况下... confirmed
和status
。
答案 1 :(得分:0)
确保您的表具有字段confirmed
,并且您已经正确注册了保护人员以将该表用作提供程序。
后卫:config/auth.php
'guards' => [
// ...
'pharmacy' => [
'driver' => 'session',
'provider' => 'pharmacies',
],
],
迁移
class CreatePharmaciesTable extends Migration
{
public function up()
{
Schema::create('pharmacies', function (Blueprint $table) {
// ...
$table->boolean('confirmed')->default(false);
});
}
// ...
}