我正在尝试获得具有文件集合的可邮寄设置。邮件控制器看起来像:
ThisWorkbook.Sheets("SomeRangeName").Select
调用mailable的控制器看起来像;
<?php
namespace App\Mail;
use App\Document;
use App\Order;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\User;
class OrderComplete extends Mailable
{
use Queueable, SerializesModels;
public $user;
public $order;
public $documents;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct(User $user, Order $order, Document $document)
{
//
$this->user = $user;
$this->order = $order;
$this->documents = $document;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->markdown('emails.customers.complete');
}
}
但我一直收到这个错误:
use App\Document;
// other code...
$documents = Document::where('order_id', $orderId)
->where('product', 'like', '%response')
->get();
Mail::to($customer)
->send(new OrderComplete($customer, $order, $documents));
我觉得这应该有用,我很困惑?
感谢
答案 0 :(得分:2)
此功能声明:
public function __construct(..., Document $document)
表示PHP将强制$document
是App\Document
的实例。
如果你想传递一个集合,你需要做:
public function __construct(..., \Illuminate\Database\Eloquent\Collection $documents)