I have the following Mailable extension in Laravel
class QualityFinal extends Mailable
{
use Queueable, SerializesModels;
public $randie;
public $report;
public function __construct($randie)
{
$this->randie = $randie;
$this->report = [];
}
public function build()
{
$this->report = QrfQualityForm::whereRandie($this->randie)->first();
$files = Storage::disk('spaces')->files("qrf/{$this->randie}");
$filename = Str::slug($this->report['employee'], '_') . '_' . Carbon::now()->format('Y-m-d') . '_Quality_Form.pdf';
$this->report->form_url = $filename;
$this->report->save();
if($this->report) {
$path = "qrf/{$this->randie}/{$filename}";
$pdf = PDF::loadView('forms.quality_final', $this->report);
Storage::disk('spaces')
->put($path, $pdf->output());
$email = $this->view('emails.quality_final', $this->report)
->subject($this->report['reporter'] . ' Quality Action Form Submission');
foreach ($files as $file) {
$email->attachFromStorageDisk('spaces', $file);
} // end for
return $email;
} else {
return 'Report not found';
} // end if
}
}
However it gives me the exception
Undefined variable: report
I have declared the variable as public so the docs say the variable should be available to the view. Am I doing something wrong?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire