77 lines
2.3 KiB
PHP
77 lines
2.3 KiB
PHP
<?php
|
|
namespace App\Mail;
|
|
|
|
use App\Models\TravelUserBookingFewo;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Storage;
|
|
|
|
class MailSendFeWoInfo extends Mailable
|
|
{
|
|
use Queueable, SerializesModels;
|
|
|
|
protected $travel_user_booking_fewo;
|
|
public $subject;
|
|
public $files;
|
|
|
|
|
|
public function __construct(TravelUserBookingFewo $travel_user_booking_fewo, $files = [])
|
|
{
|
|
$this->travel_user_booking_fewo = $travel_user_booking_fewo;
|
|
$this->subject = __('STERN TOURS Anreiseinfo FEWO');
|
|
$this->files = $files;
|
|
|
|
}
|
|
|
|
public function build()
|
|
{
|
|
$salutation = __('Dear customer').",";
|
|
if($this->travel_user_booking_fewo->travel_user){
|
|
if($this->travel_user_booking_fewo->travel_user->salutation_id == 1){
|
|
$salutation = __('Dear Sir')." ".$this->travel_user_booking_fewo->travel_user->last_name.",";
|
|
}else{
|
|
$salutation = __('Dear Mrs')." ".$this->travel_user_booking_fewo->travel_user->last_name.",";
|
|
}
|
|
}
|
|
|
|
|
|
$file1 = array(
|
|
'path' => $this->travel_user_booking_fewo->getTravelInfoPathFile(),
|
|
'name' => 'Stern-Tours-'.$this->travel_user_booking_fewo->getTravelInfoFileName(),
|
|
'mine' => 'application/pdf',
|
|
);
|
|
|
|
$message = $this->view('emails.info')
|
|
->with([
|
|
'salutation' => $salutation,
|
|
'copy1line' => $this->travel_user_booking_fewo->info_mail_text,
|
|
'copy2line' => "",
|
|
'greetings' => __('Best regards'),
|
|
'model' => $this->travel_user_booking_fewo,
|
|
]);
|
|
if ($file1['path'] && is_file($file1['path'])) {
|
|
$message->attach($file1['path'], [
|
|
'as' => $file1['name'],
|
|
'mime' => $file1['mine'],
|
|
]);
|
|
}
|
|
|
|
foreach ($this->files as $file) {
|
|
$message->attach($file->getPath(),[
|
|
'as' => $file->original_name,
|
|
'mime' => $file->mine,
|
|
]); // attach each file
|
|
}
|
|
|
|
return $message;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
//path = \Storage::disk('lead')->path($this->dir.$this->filename);
|
|
//name =
|
|
//'mine' => 'application/pdf',
|
|
|