Mails previews, Lead Passolution, Lead Country Files, LeadParticipant

This commit is contained in:
Kevin Adametz 2021-09-17 14:32:51 +02:00
parent 5e3bd3a1ba
commit ae70577289
28 changed files with 596 additions and 97 deletions

View file

@ -6,10 +6,11 @@
namespace App\Models;
use App\Models\Lead as ModelsLead;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use App\Services\Passolution;
use App\Models\Lead as ModelsLead;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Collection;
/**
* Class Lead
@ -153,7 +154,8 @@ class Lead extends Model
'participant_birthdate',
'participant_salutation_id'
];
protected $passolutionPDFs = [];
public static $lead_mail_dirs = [
11 => ['name' => 'Entwürfe', 'icon'=>'ion-md-create'],
12 => ['name' => 'Papierkorb', 'icon'=>'ion-md-trash'],
@ -340,4 +342,45 @@ class Lead extends Model
}
return $this->lead_mails->where('dir', $dir)->count();
}
public function getPassolutionPDF($create = false, $resync = false){
$nats = [];
if(count($this->passolutionPDFs)){
return $this->passolutionPDFs;
}
if(!$this->travel_country){
return $this->passolutionPDFs;
}
$destco = $this->travel_country->destco;
//default no travel_nationality
$nats['de'] = 'de';
if($this->lead_participants->count()){
foreach ($this->lead_participants as $participant){
if($participant->travel_nationality){
$nats[$participant->travel_nationality->nat] = $participant->travel_nationality->nat;
}
}
}
if(empty($nats)){
$nats['de'] = 'de';
}
foreach ($nats as $nat){
$data = [
'nat' => $nat,
'destco' => $destco,
];
$passolution = new Passolution($data);
$this->passolutionPDFs[] = $passolution->findOrCreatePDF($create, $resync);
}
return $this->passolutionPDFs;
}
public function resyncPassolutionPDF(){
return $this->getPassolutionPDF(true, true);
}
}

View file

@ -53,7 +53,9 @@ class LeadParticipant extends Model
'participant_name',
'participant_firstname',
'participant_birthdate',
'participant_salutation_id'
'participant_salutation_id',
'participant_child',
'nationality_id'
];
public function lead()
@ -65,4 +67,9 @@ class LeadParticipant extends Model
{
return $this->belongsTo(Salutation::class, 'participant_salutation_id');
}
public function travel_nationality()
{
return $this->belongsTo(TravelNationality::class, 'nationality_id');
}
}