Laravel
125
Вклад в тег
php artisan make:model Localization
protected $table = 'localization';
public function lozalizable()
{
return $this->morphTo();
}
public function lozalization(){
return $this->morphOne('App\Localization', 'lozalizable');
}
Schema::create('localization', function (Blueprint $table) {
$table->increments('id');
$table->string('field');
$table->string('language');
$table->string('value');
$table->string('lozalizable_type');
$table->integer('lozalizable_id');
$table->timestamps();
});
$article = Article::create($Atricle);
$localization = new Localization;
$localization->language = 'en';
$localization->field = 'content';
$localization->value = 'Znachenye na english yazike';
$article->localization()->save($localization); //привязываем к свежесозданному объекту Article новую локализацию
public function scopeGetLocalize($language, $field){
return $this->localization()->where(['language' => $language, 'field' => $field])-> firstOrFail()->value;
}
$article->getLocalize('en', 'title')
https://api.weather.yandex.ru/v1/forecast?geoid=2&lang=ru
User-Agent: yandex-weather-android/4.2.1
X-Yandex-Weather-Client: YandexWeatherAndroid/4.2.1
X-Yandex-Weather-Device: os=null;os_version=21;manufacturer=chromium;model=App Runtime for Chrome Dev;device_id=[DEVICE ID];uuid=[UUID];
X-Yandex-Weather-Token: [TOKEN]
X-Yandex-Weather-Timestamp: [TIMESTAMP]
X-Yandex-Weather-UUID: [UUID]
X-Yandex-Weather-Device-ID: [DEVICE ID]
Accept-Encoding: gzip, deflate
Host: api.weather.yandex.ru
Connection: Keep-Alive
md5(secret.concat(timestamp))