Robin R Robin R - 2 months ago 6x
PHP Question

Laravel 5.1 passing data to mail view doesn't work

So, I'm trying to make an e-mail view, using data the user posted. The problem is, that specific data is unreachable. I don't know how I'm supposed to get that data.

Here is my controller:

public function PostSignupForm(Request $request)
// Make's messages of faults
$messages = [
//removed them to save space

//Validation rules
$rules = [
//removed them to save space

$validator = Validator::make($request->all(), $rules, $messages);

if ($validator->fails()) {
return Redirect::back()->withInput()->withErrors($validator);

'note' => $request->get('note'),
//standard instert

* Sending the e-mails to the pilot and co-pilot
* @return none
Mail::send('emails.rittensport_signup', $request->all(), function ($message) {
$message->from(env('APP_MAIL'), 'RallyPodium & Reporting');
$message->sender(env('APP_MAIL'), 'RallyPodium & Reporting');
$message->to($request->get('piloot_email'), strtoupper($request->get('piloot_lastname')).' '.$request->get('piloot_firstname'));
$message->to($request->get('navigator_email'), strtoupper($request->get('navigator_lastname')).' '.$request->get('navigator_firstname'));
$message->subject('Uw inschrijving voor de RPR Gapersrit '. date('Y'));
$message->priority(1);//Highest priority (5 is lowest).

return Redirect::back();

Well, the view exists and the error I'm facing to is:
Undefined variable: request

This is how I try to get the data in the e-mail view:
{{ $request->get('note') }}
I already tried things like
{{ $message->note }}
And so on.


Try this:

Mail::send('emails.rittensport_signup', array("request" => $request), function (...