Laravel 5.1将数据传递到邮件视图不起作用

时间:2016-07-27 14:08:59

标签: php email laravel-5.1

所以,我正在尝试使用用户发布的数据制作电子邮件视图。问题是,特定数据无法访问。我不知道我应该如何获得这些数据。

这是我的控制器:

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();

嗯,视图存在,我面临的错误是: Undefined variable: request

这就是我尝试在电子邮件视图中获取数据的方式:{{ $request->get('note') }}我已经尝试了{{ $message->note }}$message['note']等内容。

1 个答案:

答案 0 :(得分:1)

试试这个:

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