/** * Creates a new File model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new File(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { $dir = Yii::getAlias('@app/uf'); foreach (UploadedFile::getInstances($model, 'files') as $file) { $file->saveAs($dir . '/' . $file->baseName . '.' . $file->extension); $new_file = new File(); $new_file->setAttributes($model->attributes); $new_file->file_name = $file->baseName . '.' . $file->extension; $new_file->file_path = $dir . '/' . $file->baseName . '.' . $file->extension; $new_file->table_name = 'person'; $new_file->class_name = Person::className(); $new_file->save(); } Yii::$app->getSession()->addFlash('success', "Запись \"{$model->id}\" успешно добавлена."); return $this->redirect(Url::previous() != Yii::$app->homeUrl ? Url::previous() : ['view', 'id' => $model->id]); } else { if (Yii::$app->request->referrer != Yii::$app->request->absoluteUrl) { Url::remember(Yii::$app->request->referrer ? Yii::$app->request->referrer : null); } if (!Yii::$app->request->isPost) { $model->setAttributes(Yii::$app->request->get()); } return $this->render('create', ['model' => $model]); } }
public function getPeople($list, $segment = NULL, $role = NULL) { return $this->hasMany(Person::className(), ['id' => 'user_id'])->joinWith(['list'])->viaTable('person_project', ['project_id' => 'id'], function ($query) use($list, $segment, $role) { $conditions = ['list' => $list]; // Apply segment if ($segment) { $conditions['availability'] = $segment; } // Apply role if ($role) { $conditions['role'] = $role; } $query->onCondition($conditions); })->orderBy(['person_project.availability' => SORT_DESC]); }
/** * @return \yii\db\ActiveQuery */ public function getGuests() { return $this->hasMany(Person::className(), ['prs_sec_id' => 'sec_id'])->where(['prs_active' => Person::PERSON_STATE_ACTIVE, 'prs_type' => Person::PERSON_TYPE_GUEST]); }
/** * @return \yii\db\ActiveQuery */ public function getPeople() { return $this->hasMany(Person::className(), ['user_id' => 'id']); }
/** * @inheritdoc */ public function rules() { return [[['type_id', 'person_id', 'education_type_id', 'profession_id', 'city_id', 'duration', 'rec_status_id', 'user_id'], 'integer'], [['date_start', 'date_end'], 'date', 'format' => 'dd.mm.yyyy'], [['education_type_id', 'person_id', 'firm', 'profession_id'], 'required'], [['firm'], 'string', 'max' => 128], [['type_id'], 'default', 'value' => 1], [['rec_status_id'], 'default', 'value' => 1], [['user_id'], 'default', 'value' => Yii::$app->user->id], [['note'], 'string'], [['dc'], 'safe'], ['person_id', 'exist', 'targetClass' => Person::className(), 'targetAttribute' => 'id']]; }
public function getPricipal() { return $this->hasOne(Person::className(), ['id' => 'pricipal_id']); }
public function getOwners() { return $this->hasMany(Person::className(), ['id' => 'person_id'])->viaTable('person_vacancy_role', ['vacancy_id' => 'id'], function ($query) { $query->onCondition(['role_id' => VacancyRoleHelper::OWNER]); }); }
/** * Returns the receiving Person of this Review * * @return \yii\db\ActiveQuery Person */ public function getReceiver() { return $this->hasOne(Person::className(), ['receiver_id' => 'id']); }
/** * @return \yii\db\ActiveQuery */ public function getPersons() { return $this->hasMany(Person::className(), ['prs_doc_id' => 'doc_id'])->where(['prs_type' => Person::PERSON_TYPE_CONSULTANT]); }
/** * @return \yii\db\ActiveQuery */ public function getDebtPerson() { return $this->hasOne(Person::className(), ['person_id' => 'debt_person']); }
/** * @return \yii\db\ActiveQuery */ public function getReserveStudent() { return $this->hasOne(Person::className(), ['person_id' => 'reserve_student_id']); }
public function behaviors() { return ['validateConsultant' => ['class' => MultirowsBehavior::className(), 'model' => Person::className(), 'defaultattributes' => ['prs_type' => Person::PERSON_TYPE_CONSULTANT], 'scenario' => 'createconsultant'], 'validateMedals' => ['class' => MultirowsBehavior::className(), 'model' => Docmedal::className()], 'validateMembers' => ['class' => MultirowsBehavior::className(), 'model' => Member::className()], 'access' => ['class' => AccessControl::className(), 'rules' => [['allow' => true, 'actions' => ['list', 'create', 'view', 'update', 'logout', 'delete', 'deletefile'], 'roles' => ['@']], ['allow' => true, 'actions' => ['index', 'register', 'calendar', 'guest', 'login'], 'roles' => ['?', '@']], ['allow' => true, 'actions' => ['regthankyou', 'confirm'], 'roles' => ['?', '@']]]]]; }
/** * @return \yii\db\ActiveQuery */ public function getTransactionPerson() { return $this->hasOne(Person::className(), ['person_id' => 'transaction_person_id']); }
/** * Returns all studentAssistants for this course * * @return \yii\db\ActiveQuery Person */ public function getStudentAssistants() { return $this->hasMany(Person::className(), ['id' => 'person_id'])->viaTable('person_course_role', ['course_id' => 'id'], function ($query) { $query->onCondition(['role_id' => CourseRoleHelper::STUDENTASSISTANT]); }); }
/** * @return \yii\db\ActiveQuery */ public function getPeople() { return $this->hasMany(Person::className(), ['recommend_by' => 'person_id']); }
/** * @return \yii\db\ActiveQuery */ public function getPerson() { return $this->hasOne(Person::className(), ['id' => 'person_id']); }
public function getConnecter() { return $this->hasOne(Person::className(), ['id' => 'connecter_id']); }