'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; } }