0
はユーザー&セッションガードのための私のモデルである:DB値に基づいてlaravel sessionguardのログインをブロックする方法は?ここ
<?php namespace App;
use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
use Illuminate\Support\Facades\DB;
class User extends Model implements AuthenticatableContract, CanResetPasswordContract {
use Authenticatable, CanResetPassword;
protected $table = 'users';
protected $fillable = ['name', 'email', 'password', 'type', 'course_id', 'address', 'phone', 'status', 'avatar'];
protected $hidden = ['password', 'remember_token'];
public function getUserLocked() {
$result=DB::table('users')->where('status', 'locked')->get();
return $result;
}
}
public function login(AuthenticatableContract $user, $remember = false)
{
$u=new User();
$result= $u->getUserLocked();
foreach ($result as $locked) {
if ($locked->id== "locked");
return;
}
$this->updateSession($user->getAuthIdentifier());
// If the user should be permanently "remembered" by the application we will
// queue a permanent cookie that contains the encrypted copy of the user
// identifier. We will then decrypt this later to retrieve the users.
if ($remember) {
$this->createRememberTokenIfDoesntExist($user);
$this->queueRecallerCookie($user);
}
// If we have an event dispatcher instance set we will fire an event so that
// any listeners will hook into the authentication events and run actions
// based on the login and logout events fired from the guard instances.
$this->fireLoginEvent($user, $remember);
$this->setUser($user);
}
私が欲しいもの値がロックされるたびにログインが失敗しますです。しかし、ロックされているかどうかをチェックするコードをコメントアウトしない限り、すべてのログインに失敗しています。どこが間違っているのか。 Userモデルでも静的関数を試してみました。
> handleErrorの( '8'、「未定義の変数: 'lock'、 'C:\ wamp64 \ www \ laravel \ dev.oasis-portal.my \ vendor \ laravel \ framework \ src \ Illuminate \ Auth \ SessionGuard.php'、 '427'、array( 'user' =>オブジェクト(User)、 'remember' => false、 'u' => object(User)、 'result' => object(stdClass)))SessionGuard.php 427 –
あなたはダブリング$$をどこかに持っているかもしれません - ただ推測して – DorienCragen
$ resultを検索する方法を教えてください。 –