Nuevos cambios hechos de diseño
This commit is contained in:
29
desarrollo2/app/Models/City.php
Normal file
29
desarrollo2/app/Models/City.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App;
|
||||
|
||||
class City extends Model
|
||||
{
|
||||
public function getTranslation($field = '', $lang = false){
|
||||
$lang = $lang == false ? App::getLocale() : $lang;
|
||||
$city_translation = $this->hasMany(CityTranslation::class)->where('lang', $lang)->first();
|
||||
return $city_translation != null ? $city_translation->$field : $this->$field;
|
||||
}
|
||||
|
||||
public function city_translations(){
|
||||
return $this->hasMany(CityTranslation::class);
|
||||
}
|
||||
|
||||
public function country()
|
||||
{
|
||||
return $this->belongsTo(Country::class);
|
||||
}
|
||||
|
||||
public function state()
|
||||
{
|
||||
return $this->belongsTo(State::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user