83 lines
2.3 KiB
PHP
83 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use PHPUnit\Framework\Constraint\Count;
|
|
|
|
/**
|
|
* App\Models\Country
|
|
*
|
|
* @property int $id
|
|
* @property string $code
|
|
* @property string $phone
|
|
* @property string $en
|
|
* @property string $de
|
|
* @property string $es
|
|
* @property string $fr
|
|
* @property string $it
|
|
* @property string $ru
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereCode($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereDe($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereEn($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereEs($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereFr($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereIt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country wherePhone($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereRu($value)
|
|
* @mixin \Eloquent
|
|
*/
|
|
class Country extends Model
|
|
{
|
|
protected $table = 'countries';
|
|
|
|
|
|
public function getLocated($lang = 'de'){
|
|
|
|
$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;
|
|
}
|
|
return $this->de;
|
|
}
|
|
|
|
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 getCountryIdByPhone($phone){
|
|
if($phone == null){
|
|
return null;
|
|
}
|
|
$r = Country::where('phone', '=', $phone)->first();
|
|
if($r){
|
|
return $r->id;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
}
|