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

@ -34,6 +34,12 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent whereUpdatedAt($value)
* @mixin \Eloquent
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent findSimilarSlugs($attribute, $config, $slug)
* @property string|null $identifier
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent whereIdentifier($value)
* @property array|null $object
* @property int|null $pos
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent whereObject($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent wherePos($value)
*/
class CmsContent extends Model
{
@ -45,7 +51,12 @@ class CmsContent extends Model
protected $table = 'cms_contents';
protected $fillable = [
'name', 'slug', 'field', 'text', 'full_text', 'integer', 'decimal',
'name', 'slug', 'identifier', 'field', 'text', 'full_text', 'object', 'integer', 'decimal', 'pos',
];
protected $casts = [
'object' => 'array',
'pos' => 'int'
];
public $timestamps = false;

View file

@ -3,7 +3,9 @@
namespace App\Models\Sym;
use App\Models\Booking;
use App\Models\GeneralFile;
use App\Models\Lead;
use App\Models\TravelCountryService;
use Illuminate\Database\Eloquent\Model;
@ -40,6 +42,13 @@ use Illuminate\Database\Eloquent\Model;
* @property-read int|null $bookings_count
* @property array|null $contact_emails
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry whereContactEmails($value)
* @property array|null $mail_dirs
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry whereMailDirs($value)
* @property string|null $mail_dir_name
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry whereMailDirName($value)
* @property-read \App\Models\TravelCountry|null $stern_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
{
@ -53,6 +62,8 @@ class TravelCountry extends Model
'is_customer_country',
'active_backend',
'contact_lands',
'mail_dir_name',
'mail_dirs',
'contact_headline',
'contact_text_1',
'contact_text_2',
@ -63,7 +74,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;
@ -77,6 +88,16 @@ class TravelCountry extends Model
return $this->hasMany(Booking::class, 'travel_country_id', 'id');
}
public function stern_travel_country()
{
return $this->hasOne(\App\Models\TravelCountry::class, 'crm_id', 'id');
}
public function travel_country_services()
{
return $this->hasMany(TravelCountryService::class, 'crm_travel_country_id', 'id')->orderBy('pos', 'DESC');
}
public function getCountryLands(){
$ret = [];
if($this->contact_lands){
@ -90,4 +111,22 @@ 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::find($travel_country_id)){
$ret[$travel_country->id] = $travel_country;
}
}
}else{
$ret[$this->id] = $this;
}
return $ret;
}
}