mercredi 27 juillet 2016

Laravel 5.1 passing data to mail view doesn't work

So, I'm tryting 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 suppost 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);
        }

        DB::table('rittensport')->insert([
            '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: I already tried things like , $message['note'] And so on... Can someone PLEASE help me out?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire