namespace App\Http\Controllers;
class FormController extends Controller
{
public function __construct(AsyncResponse $response)
{
$this->response = $response;
}
public function registration()
{
...
if ($error) {
$this->response->bigPipe()->require("require('Toastr').error()", [
$error,
]);
return $this->response->send();
}
...
return $this->response->send();
}
}
This form is sent asynchronously, if the backend detects invalid data in the form, it will display them via toast.