Array
(
[0] => app\models\Users Object
(
[id] =>
[username] =>
[password] =>
[authKey] =>
[_attributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 1
[username] => victor
[password] => 12344321
[authKey] => 12344321
[accessToken] => 12344321
)
[_oldAttributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 1
[username] => victor
[password] => 12344321
[authKey] => 12344321
[accessToken] => 12344321
)
[_related:yii\db\BaseActiveRecord:private] => Array
(
)
[_errors:yii\base\Model:private] =>
[_validators:yii\base\Model:private] =>
[_scenario:yii\base\Model:private] => default
[_events:yii\base\Component:private] => Array
(
)
[_behaviors:yii\base\Component:private] => Array
(
)
)
[1] => app\models\Users Object
(
[id] =>
[username] =>
[password] =>
[authKey] =>
[_attributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 2
[username] => admin
[password] => 123443221
[authKey] => 12344321
[accessToken] => 12344321
)
[_oldAttributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 2
[username] => admin
[password] => 123443221
[authKey] => 12344321
[accessToken] => 12344321
)
[_related:yii\db\BaseActiveRecord:private] => Array
(
)
[_errors:yii\base\Model:private] =>
[_validators:yii\base\Model:private] =>
[_scenario:yii\base\Model:private] => default
[_events:yii\base\Component:private] => Array
(
)
[_behaviors:yii\base\Component:private] => Array
(
)
)
)
Вот что мне выдает команда
$user = Users::find()->all();
Затем мне нужно перебрать все поля и найти нужное мне
public static function findByUsername($username)
{
$user = Users::find()->all();
foreach ($user as $usr) {
print_r($usr);
if (strcasecmp($usr['username'], $username) === 0) {
return new static($usr);
}
}
return null;
}
Вот тут. Но ничего не выходит как исправить? Что я делаю не так?