mivita/app/Mail/MailInfo.php
2020-05-06 15:43:53 +02:00

86 lines
No EOL
3.4 KiB
PHP

<?php
namespace App\Mail;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class MailInfo extends Mailable
{
use Queueable, SerializesModels;
protected $user;
protected $action;
public $subject;
public function __construct($user, $action)
{
$this->user = $user;
$this->action = $action;
if($this->action === "delete_membership"){
$this->subject = 'Mitgliedschaft beenden - beantragt';
}
if($this->action === "check_is_like_customer"){
$this->subject = 'Kunden überprüfen - Kundenhoheit';
}
}
public function build()
{
$content = "";
if($this->action === "delete_membership"){
$content .= __(strtoupper($this->user->account->salutation))." ";
$content .= $this->user->account->first_name." ".$this->user->account->last_name."\n";
$content .= $this->user->account->address."\n";
$content .= $this->user->account->zipcode." ".$this->user->account->city."\n";
$content .= $this->user->account->country_id ? $this->user->account->country->de."\n\n" : "\n\n";
if($this->user->account->phone){
$content .= "Telefon: ";
$content .= $this->user->account->pre_phone_id ? $this->user->account->pre_phone->phone." " : " ";
$content .= $this->user->account->phone;
}
if($this->user->account->mobil){
$content .= "Mobil: ";
$content .= $this->user->account->pre_mobil_id ? $this->user->account->pre_mobil->phone." " : " ";
$content .= $this->user->account->mobil;
}
$content .= "E-Mail: ".$this->user->email;
$copy1line = "Infos zum Berater:"."\n";
$button = "zum Berater";
$title = "Ein Berater möchte seine Mitgliedschaft beenden.";
$url = route('admin_lead_edit', $this->user->id).'?show=check_lead';
}
if($this->action === "check_is_like_customer") {
$copy1line = "Hier geht es zum Kunden:"."\n";
$button = "zum Kunden";
$title = "Ein Kunden muss überprüfen werden und einem Berater zugeordnet werden, da die Adresse nicht eindeutig ist.";
$url = route('admin_customer_edit', $this->user->id);
$content .= $this->user ? 'Firma: '.$this->user->billing_company."\n" : '';
$content .= \App\Services\HTMLHelper::getSalutationLang($this->user->billing_salutation)." ";
$content .= $this->user->billing_firstname." ";
$content .= $this->user->billing_lastname."\n";
$content .= $this->user->billing_address;
$content .= $this->user->billing_address_2 ? '/ '.$this->user->billing_address_2."\n" : "\n";
$content .= $this->user->billing_zipcode." ";
$content .= $this->user->billing_city."\n";
$content .= $this->user->billing_email."\n";
$content .= $this->user->billing_phone."\n";
$content .= $this->user->billing_country->getLocated();
}
return $this->view('emails.info')->with([
'url' => $url,
'title' => $title,
'button' => $button,
'copy1line' => $copy1line,
'copy2line' => __('email.copy2line'),
'content' => $content,
]);
}
}