255], [['salary_currency'], 'string', 'max' => 100], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'employer_id' => 'Работодатель', 'hh_id' => 'Hh ID', 'title' => 'Заголовок', 'url' => 'Url', 'salary_from' => 'З.П. от', 'salary_to' => 'З.П. до', 'salary_currency' => 'З.П. валюта', 'address' => 'Адрес', 'dt_add' => 'Дата', ]; } public function gethhcompany() { return $this->hasOne(Hh::class, ['hh_id' => 'employer_id']); } public static function createFromHH($data) { if (!self::find()->where(['hh_id' => $data->item->id])->exists()) { $j = new self(); $j->dt_add = time(); $j->title = $data->item->name; $j->hh_id = $data->item->id; $j->url = $data->item->alternate_url; $j->employer_id = $data->item->employer->id; if (!empty($data->item->address)) { $j->address = $data->item->address->city . ', ' . $data->item->address->street . ', ' . $data->item->address->building; } if (!empty($data->item->salary)) { $j->salary_from = $data->item->salary->from; $j->salary_to = $data->item->salary->to; $j->salary_currency = $data->item->salary->currency; } return $j->save(); } return false; } }