'bool', 'translate' => 'bool', 'supply_country' => 'bool', 'eu_country' => 'bool', 'own_eur' => 'bool', 'currency' => 'bool', 'currency_calc' => 'bool', 'attr' => 'array' ]; protected $fillable = [ 'code', 'phone', 'en', 'de', 'es', 'fr', 'it', 'ru', 'supply_country', 'eu_country', 'switch', 'translate', 'own_eur', 'currency', 'currency_unit', 'currency_calc', 'currency_faktor', 'active', 'attr', ]; public function country_prices() { return $this->hasMany(CountryPrice::class, 'country_id'); } public function getLocated($lang = false){ if(!$lang){ $lang = \App::getLocale(); } if($lang === 'de'){ return $this->de; } if($lang === 'en'){ return $this->en; } if($lang === 'es'){ return $this->es; } if($lang === 'fr'){ return $this->fr; } if($lang === 'it'){ return $this->it; } if($lang === 'ru'){ return $this->ru; } //search by trans return $this->de; } public function getAttrByKey($key) { $name = 'attr'; if (!empty($this->{$name}[$key])) { return $this->{$name}[$key]; } return ""; } public static function getCountryIdByCode($code){ if($code == null){ return null; } $r = Country::where('code', '=', $code)->first(); if($r){ return $r->id; } return null; } public static function getCountryIdByCodeOrOne($code){ if($code == null){ return 1; } $r = Country::where('code', '=', $code)->first(); if($r){ return $r->id; } return 1; } public static function getCountryIdByPhone($phone){ if($phone == null){ return null; } $r = Country::where('phone', '=', $phone)->first(); if($r){ return $r->id; } return null; } }