在我的Laravel Web应用程序中,我在以下行中遇到以下错误。当Laravel电子邮件触发器
解析错误:语法错误,意外'?',期待变量(T_VARIABLE)
$order=array();
$order['contactname']=$customername;
$order['contactnumber']=$cusconnum;
$order['pickupaddress']=$request->input('pickupaddress');
$order['deliveraddress']=$request->input('deliveryaddress');
$order['pickupdate']=$request->input('pickupdate');
$order['refnos']= $bookingpre."".$curbookingid;
$myemail="karthik@w3cert.in";
Mail::to($myemail)->send(new OrderBooked($order)); /* Error Raised Line */
以下订购邮件的代码
OrderBooked.php
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class OrderBooked extends Mailable
{
use Queueable, SerializesModels;
protected $order;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct(array $order)
{
$this->order = $order;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->from('support@greatmovers.com.my')->markdown('emails.orders.booked') ->with(['contactname' => $this->order['contactname'],'contactnumber' => $this->order['contactnumber'],'pickupaddress' => $this->order['pickupaddress'],'deliveraddress' => $this->order['deliveraddress'],'pickupdate' => $this->order['pickupdate'],'refnos' => $this->order['refnos'],]);
}
}
答案 0 :(得分:-1)
您在下一行的末尾有不必要的逗号,只需删除它。
public function build()
{
return $this->from('support@greatmovers.com.my')->markdown('emails.orders.booked') ->with(['contactname' => $this->order['contactname'],'contactnumber' => $this->order['contactnumber'],'pickupaddress' => $this->order['pickupaddress'],'deliveraddress' => $this->order['deliveraddress'],'pickupdate' => $this->order['pickupdate'],'refnos' => $this->order['refnos']]);
}