Fewo Mails / Booking Country Services

This commit is contained in:
Kevin Adametz 2020-05-28 19:03:42 +02:00
parent b9c26d06d0
commit 48a6eb2282
154 changed files with 7761 additions and 1643 deletions

View file

@ -60,6 +60,15 @@ use Illuminate\Support\Str;
* @property-read int|null $travel_nationality_requirements_count
* @property array|null $contact_emails
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereContactEmails($value)
* @property array|null $mail_dirs
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereMailDirs($value)
* @property string $mail_dir_name
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereMailDirName($value)
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\GeneralFile[] $general_files
* @property-read int|null $general_files_count
* @property-read \App\Models\Sym\TravelCountry|null $crm_travel_country
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\TravelCountryService[] $travel_country_services
* @property-read int|null $travel_country_services_count
*/
class TravelCountry extends Model
{
@ -68,7 +77,6 @@ class TravelCountry extends Model
protected $table = 'travel_country';
protected $fillable = [
'name',
'slug',
@ -76,6 +84,8 @@ class TravelCountry extends Model
'text_before',
'text_after',
'contact_lands',
'mail_dir_name',
'mail_dirs',
'contact_headline',
'contact_text_1',
'contact_text_2',
@ -90,7 +100,7 @@ class TravelCountry extends Model
];
protected $casts = ['contact_lands' => 'array', 'contact_emails' => 'array'];
protected $casts = ['contact_lands' => 'array', 'mail_dirs' => 'array', 'contact_emails' => 'array'];
public $timestamps = false;
@ -105,11 +115,26 @@ class TravelCountry extends Model
return $this->belongsTo('App\Models\Page', 'feedback_page_id', 'id');
}
public function crm_travel_country()
{
return $this->belongsTo(\App\Models\Sym\TravelCountry::class, 'crm_id', 'id');
}
public function travel_nationality_requirements()
{
return $this->hasMany('App\Models\TravelNationalityRequirement', 'travel_country_id', 'id');
}
public function general_files()
{
return $this->hasMany(GeneralFile::class, 'travel_country_id', 'id');
}
public function travel_country_services()
{
return $this->hasMany(TravelCountryService::class, 'travel_country_id', 'id')->orderBy('pos', 'DESC');
}
public function setSlugAttribute( $value ) {
if(!isset($value) || $value == ""){
$this->attributes['slug'] = Str::slug(pre_slug($this->name), '-');
@ -131,6 +156,23 @@ class TravelCountry extends Model
return $ret;
}
public function getMailDirs($id){
return isset($this->mail_dirs[$id]) ? $this->mail_dirs[$id] : [];
}
public function getContactLandsModels(){
$ret = [];
if($this->contact_lands){
foreach ($this->contact_lands as $travel_country_id){
if($travel_country = TravelCountry::where('crm_id', $contact_land_id)->first()){
$ret[$travel_country->id] = $travel_country;
}
}
}else{
$ret[$this->id] = $this;
}
return $ret;
}
public function getNationalityRequirement($travel_nationality_id){
$model = TravelNationalityRequirement::where('travel_country_id', $this->id)->where('travel_nationality_id', $travel_nationality_id)->first();