Sometimes, you may wish to ignore a given ID during unique validation. For example, consider an "update profile" screen that includes the user's name, email address, and location. You will probably want to verify that the email address is unique. However, if the user only changes the name field and not the email field, you do not want a validation error to be thrown because the user is already the owner of the email address in question.
To instruct the validator to ignore the user's ID, we'll use the Rule class to fluently define the rule. In this example, we'll also specify the validation rules as an array instead of using the | character to delimit the rules:
Validator::make($data, [
'email' => [
'required',
Rule::unique('users')->ignore($user->id),
],
]);
$login = $_POST['login'];
$hash = password_hash($_POST['password']);
$login = $_POST['login'];
$password = $_POST['password']; // не хешируем
SELECT * FROM users WHERE login = '$login'
if (password_verify($password, $hash_from_db)) {
// пользователь аутентифицирован
} else {
// пара логин/пароль неверная
}
из-за того, что открывающий тег <?php связывается не с закрывающим тегом ?>, а со знаком >,
$select.forEach(item => {
item.addEventListener('click', function () {
$select.filter(i => i !== item).each(i => i.classList.remove('_select--opened'));
this.classList.toggle('_select--opened');
});
});
$select.forEach(item => {
item.addEventListener('click', function () {
- $select.filter(i => i !== item).each(i => i.classList.remove('_select--opened'));
+ Aray.from($select).filter(i => i !== item).forEach(i => i.classList.remove('_select--opened'));
this.classList.toggle('_select--opened');
});
})