M
M
Maxim2020-11-27 15:41:44
Laravel
Maxim, 2020-11-27 15:41:44

How is it possible and correct to add html with a controller in laravel?

Hello. Using the controller, I send the form to mail, after which the page reloads. Is it possible somehow to add html using a controller? I would like to notify the user when the form is submitted. I do not consider the option of redirecting to a separate page

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Sarvarov, 2020-11-27
@Rus_Bear

controller:

public function handleForm(Request $request)
{
    // dispatch(...); Тут отправляем Email

    return back()->withSuccess('Письмо успешно отправлено!');
}

Blade (above form): alerts.blade.php
@include('includes.alerts')

@if (($isSuccess = isset($success)) || isset($error))
    <div class="alert {{ $isSuccess ? 'alert-success' : 'alert-error' }} mb-3">
        <p>{{ $success ?? $error  }}</p>
    </div>
@endif

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question