I'm using Laravel to develop my project, and I want to return a SweetAlert error message when the user DOES NOT MARK the Recaptcha. I coded this in LoginController.php:
use App\Providers\SweetAlertServiceProvider;
protected function validateLogin(Request $request)
{
$request->validate([
$this->username() => 'required|string',
'password' => 'required|string',
'g-recaptcha-response' => ['required' , new Recaptcha]
],[
'g-recaptcha-response.required' => alert()
->error('Bad','Attempt')->persistent('Ok')
]);
}
Instead of showing an alert, it returns the following message.
Error Object of class UxWeb\SweetAlert\SweetAlertNotifier could not be converted to string
However, I have already added this line to config/app.php in the provider's section.
UxWeb\SweetAlert\SweetAlertServiceProvider::class
So what's going wrong here? What else should I have done to return this alert message?