parent
f03862b523
commit
1a43060996
42 changed files with 1160 additions and 83 deletions
|
|
@ -30,37 +30,80 @@ use PHPUnit\Framework\Constraint\Count;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country query()
|
||||
* @property int|null $active
|
||||
* @property array|null $trans
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereTrans($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereUpdatedAt($value)
|
||||
* @property string|null $trans_name
|
||||
* @property array|null $attr
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereAttr($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereTransName($value)
|
||||
*/
|
||||
class Country extends Model
|
||||
{
|
||||
protected $table = 'countries';
|
||||
|
||||
protected $casts = ['trans_name' => 'array', 'attr' => 'array'];
|
||||
|
||||
public function getLocated($lang = 'de'){
|
||||
protected $fillable = [
|
||||
'code', 'phone', 'en', 'de', 'es', 'fr', 'it', 'ru', 'active', 'trans_name', 'attr'
|
||||
];
|
||||
|
||||
$lang = \App::getLocale();
|
||||
public function getLocated($lang = false){
|
||||
|
||||
if($lang == 'de'){
|
||||
if(!$lang){
|
||||
$lang = \App::getLocale();
|
||||
|
||||
}
|
||||
if($lang === 'de'){
|
||||
return $this->de;
|
||||
}
|
||||
if($lang == 'en'){
|
||||
if($lang === 'en'){
|
||||
return $this->en;
|
||||
}
|
||||
if($lang == 'es'){
|
||||
if($lang === 'es'){
|
||||
return $this->es;
|
||||
}
|
||||
if($lang == 'fr'){
|
||||
if($lang === 'fr'){
|
||||
return $this->fr;
|
||||
}
|
||||
if($lang == 'it'){
|
||||
if($lang === 'it'){
|
||||
return $this->it;
|
||||
}
|
||||
if($lang == 'ru'){
|
||||
if($lang === 'ru'){
|
||||
return $this->ru;
|
||||
}
|
||||
|
||||
//search by trans
|
||||
|
||||
if($val = $this->getTrans('name', $lang)){
|
||||
return $val;
|
||||
}
|
||||
return $this->de;
|
||||
}
|
||||
|
||||
public function getTrans($key, $lang)
|
||||
{
|
||||
$key = 'trans_' . $key;
|
||||
if (!empty($this->{$key}[$lang])) {
|
||||
return $this->{$key}[$lang];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue