从模态传递时出现htmlentities错误

时间:2016-04-25 14:50:12

标签: laravel

Laravel的新手,请光着。

错误:

htmlentities() expects parameter 1 to be string, object given (View: /var/www/html/willow/resources/views/emails/valuation.blade.php)

发送它的模式

{!! Form::open(['action' => ['EnquiryController@valuationRequest']]) !!}
                <div class="form-group">
                    {!! Form::text('name', null, ['class' => 'form-control has-feedback', 'placeholder' => 'Name']) !!}
                </div>
                <div class="form-group">
                    {!! Form::text('email', null, ['class' => 'form-control has-feedback', 'placeholder' => 'Email Address']) !!}
                </div>
                <div class="form-group">
                    {!! Form::text('telephone', null, ['class' => 'form-control has-feedback', 'placeholder' => 'Telephone Number']) !!}
                </div>
                <div class="form-group">
                    {!! Form::text('house_number', null, ['class' => 'form-control has-feedback', 'placeholder' => 'House name / number']) !!}
                </div>
                <div class="form-group">
                    {!! Form::text('postcode', null, ['class' => 'form-control has-feedback', 'placeholder' => 'Postcode']) !!}
                </div>
                <div class="form-group">
                    {!! Form::textarea('message', null, ['class' => 'form-control has-feedback', 'placeholder' => 'Message', 'rows' => '5']) !!}
                </div>
                <div class="form-group">
                    <input type="submit" class="button black" value="Register">
                </div>
            {!! Form::close() !!}

和功能:

public function valuationRequest(ValuationRequest $request)
 {       
    // dd($request->all());
         Mail::send('emails.valuation',
                ['name' => $request['name'],
                'email' => $request['email'],
                'telephone' => $request['telephone'],
                'house_number' => $request['house_number'],
                'postcode' => $request['postcode'],
                'message' => $request['message'],
                ],
            function ($message) use ($request) {
                $message->to('paolo@bigg.co.uk', 'Paolo Resteghini')->subject('Valuation Request - Willow Lettings');
            });
         Session::flash('flash_message', 'Your request has been sent.');
     return redirect(URL::previous());
}

DD的内容非常完美。所有请求都按预期填充,但在尝试通过函数的其余部分时,它会因上述错误而失败。

emails.valuation:

Hello, <br><br>

You have received a new valuation request via the Willow Lettings website. Here they are: <br><br>

<b>Name:</b> {{ $name }}<br>
<b>Email:</b> {{ $email }}<br>
<b>Phone:</b> {{ $telephone }}<br>
<b>House number:</b> {{ $house_number }}<br><br>
<b>Postcode:</b> {{ $postcode }}<br><br>
{{ $message }}

1 个答案:

答案 0 :(得分:1)

最有可能的是,这是message变量的问题。正如您在docs

中看到的那样
  

注意:$message变量始终传递给电子邮件视图,并允许内联嵌入附件。因此,您应该避免在视图有效负载中传递message变量。

换句话说,您应该将message更改为其他内容,例如msg

'msg' => $request['message'],

然后,在您的刀片文件中,反映出这一变化:

{{ $msg }}