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.
Sorry forgot to mention. $status stores string from translation, checked it straight away. it's not that.
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.
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; ?>Try
<?php echo Session::get('wiadomosc'); ?>
You may need a use statement in controller to use Session:
use Illuminate\Support\Facades\Session;
~~~.
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
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
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.
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
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community