У меня есть запрос пользовательской формы, в котором я делаю некоторые дополнительные логи проверки c, и я хочу добавить ошибку, если моя логи c не удается, но я получаю эту ошибку:
Вызов ошибки функции-члена () в null
Вот мой пользовательский запрос:
if (!empty($this->get('new_password')) && !empty($this->get('current_password'))) {
if (
!Auth::attempt([
'email' => $this->get('email'),
'password' => $this->get('current_password'),
'status' => 'pending'
])
) {
$this->validator->errors()->add('current_password', 'Something is wrong with this field!');
}
}
return [
'first_name' => 'required|min:1|max:190',
];
РЕДАКТИРОВАТЬ полный класс
class ProfileRequest extends FormRequest
{
public function authorize()
{
return Auth::check();
}
public function rules()
{
if (!empty($this->get('new_password')) && !empty($this->get('current_password'))) {
if (
!Auth::attempt([
'email' => $this->get('email'),
'password' => $this->get('current_password'),
'status' => 'pending'
])
) {
$this->validator->getMessageBag()->add('current_password', 'Something is wrong with this field!');
}
}
return [
'first_name' => 'required|min:1|max:190',
];
}
}