Support the ongoing development of Laravel.io →
posted 9 years ago
Input Blade
Last updated 2 years ago.
0

Comment out your return and print_r $status just above return to see if you get anything there. If you don't then there's an error in the above code.

Last updated 9 years ago.
0

Sorry forgot to mention. $status stores string from translation, checked it straight away. it's not that.

0

Are you using Laravel 4 or 5?

0

Laravel 5

0

From docs, have you tryed session:

Returning A Redirect With Flash Data

Redirecting to a new URL and flashing data to the session are typically done at the same time. So, for convenience, you may create a RedirectResponse instance and flash data to the session in a single method chain:

return redirect('user/login')->with('message', 'Login Failed');

Or just try view::make again instead of a redirect.

Last updated 9 years ago.
0

Same thing:

Controller: $status = \Lang::get('messages.notsent');

        if (!empty($_POST['name']) && !empty($_POST['mail']) && !empty($_POST['email'])) {
            $wiadomosc = 'example message';
            \Mail::raw($wiadomosc, function($message)
            {
                $message->to('[email protected]', 'wow')->subject('Wiadomość ze strony WWW!');
            });
            $status = \Lang::get('messages.sent');
        }

return redirect("/#kontakt")->with('wiadomosc', $status);

View:

<?php if (isset($wiadomosc)) echo $wiadomosc; ?>
0

Try

 <?php echo Session::get('wiadomosc'); ?>  

You may need a use statement in controller to use Session:

use Illuminate\Support\Facades\Session;
~~~.
Last updated 9 years ago.
0

thanks jimgwhit, it's ok with sessions actually.

I just thought that if there's something build it in framework to pass message it will work - but for some reason it's not working.

Slowly I need to admit that I never had problems like that in Zend:P

0

While the session class do work, thats not the way its designed. The $status variabele is only registered in the closure methode. Not outside. You can make it a global variable if you want to use it outside the closure.

But maybe its better to check what the RAW() method returns. Maybe there is some information there to determine if the mail is send correctly

0

That's exactly the way it is designed in the docs, on a redirect. However I agree that it can also be assigned as a global, that's a good idea.

Last updated 9 years ago.
0

What i meant was that setting the $status variable in the mail closure won't change the $status variable outside the closure.

What jimgwhit says about Session::get is true. You can also check if it exists with Session::has(). But this will always be the message messages.notsent because of the first alinea of my comment

0

Sign in to participate in this thread!

Eventy

Your banner here too?

ensimek ensimek Joined 26 Apr 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.