예제 #1
0
 public function action()
 {
     // подготавливаю данные
     $country = HD::find($this->country)->getField('name');
     $town = HDtown::find($this->town)->getField('name');
     $datetime = $this->date->format('Y-m-d') . ' ' . $this->time;
     // получаю данные Дизайна Человека
     $extractor = new \app\modules\HumanDesign\calculate\YourHumanDesignRu();
     $data = $extractor->calc(new \DateTime($datetime), $country, $town);
     // сохраняю картинку
     $url = new \cs\services\Url($data->image);
     $path = new SitePath('/upload/HumanDesign');
     $path->add([Yii::$app->user->id, 8, $url->getExtension()]);
     $path->write($url->read());
     $data->image = $path->getPath();
     // обновляю пользовтельские данные
     /** @var \app\models\User $user */
     $user = Yii::$app->user->identity;
     $fields = ['human_design' => $data->getJson(), 'birth_date' => $this->date->format('Y-m-d'), 'birth_time' => $this->time . ':00', 'birth_country' => $this->country, 'birth_town' => $this->town];
     $user->update($fields);
     return true;
 }
예제 #2
0
파일: User.php 프로젝트: Makeyko/galaxysss
 /**
  * Возвращает место рождения в виде строки
  *
  * @return string
  */
 public function getBirthPlace()
 {
     $c = $this->getField('birth_country');
     $t = $this->getField('birth_town');
     $arr = [];
     if ($c) {
         $country = HD::find($c);
         if ($country) {
             $arr[] = $country->getField('title');
         }
     }
     if ($t) {
         $town = HDtown::find($t);
         if ($town) {
             $arr[] = $town->getField('title');
         }
     }
     if (count($arr) > 0) {
         return join(', ', $arr);
     } else {
         return '';
     }
 }
예제 #3
0
 /**
  * AJAX
  *
  * REQUEST:
  * - id - int - идентификатор
  *
  * @return array
  */
 public function actionProfile_human_design_ajax()
 {
     $id = self::getParam('id');
     $item = HD::find($id);
     $items = HDtown::query(['country_id' => $id])->select(['id', 'title'])->all();
     return self::jsonSuccess(['item' => ['sub_type' => $item->getField('sub_type')], 'items' => $items]);
 }