137 lines
5.3 KiB
PHP
137 lines
5.3 KiB
PHP
<?php
|
|
|
|
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;
|
|
|
|
|
|
/**
|
|
* App\Models\Sym\TravelCountry
|
|
*
|
|
* @property int $id
|
|
* @property string $name
|
|
* @property int|null $is_customer_country
|
|
* @property int|null $active_backend
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry whereActiveBackend($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry whereIsCustomerCountry($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry whereName($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry query()
|
|
* @property string|null $contact_headline
|
|
* @property string|null $contact_text_1
|
|
* @property string|null $contact_text_2
|
|
* @property string|null $contact_text_3
|
|
* @property string|null $contact_text_4
|
|
* @property string|null $contact_footer
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry whereContactFooter($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry whereContactHeadline($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry whereContactText1($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry whereContactText2($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry whereContactText3($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry whereContactText4($value)
|
|
* @property array|null $contact_lands
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry whereContactLands($value)
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Booking[] $bookings
|
|
* @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
|
|
* @property string|null $destco
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry whereDestco($value)
|
|
* @property string|null $visum_text
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelCountry whereVisumText($value)
|
|
* @mixin \Eloquent
|
|
*/
|
|
class TravelCountry extends Model
|
|
{
|
|
|
|
protected $connection = 'mysql';
|
|
|
|
protected $table = 'travel_country';
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'destco',
|
|
'is_customer_country',
|
|
'active_backend',
|
|
'contact_lands',
|
|
'mail_dir_name',
|
|
'mail_dirs',
|
|
'contact_headline',
|
|
'contact_text_1',
|
|
'contact_text_2',
|
|
'contact_text_3',
|
|
'contact_text_4',
|
|
'contact_footer',
|
|
'contact_emails',
|
|
'visum_text',
|
|
];
|
|
|
|
protected $casts = ['contact_lands' => 'array', 'mail_dirs'=>'array', 'contact_emails' => 'array'];
|
|
|
|
public $timestamps = false;
|
|
|
|
/*public function leads()
|
|
{
|
|
return $this->hasMany(Lead::class, 'travelcountry_id', 'id');
|
|
}*/
|
|
|
|
public function bookings()
|
|
{
|
|
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){
|
|
foreach ($this->contact_lands as $travel_country_id){
|
|
if($travel_country = TravelCountry::find($travel_country_id)){
|
|
$ret[$travel_country->id] = $travel_country->name;
|
|
}
|
|
}
|
|
}else{
|
|
$ret[$this->id] = $this->name;
|
|
}
|
|
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;
|
|
}
|
|
}
|