コード例 #1
0
 public function createProfile()
 {
     $profile = new Profile();
     $profile->attributes = ['event_id' => $this->getEvent()->id, 'name' => $this->name, 'age' => $this->age, 'gender' => $this->gender, 'height' => $this->height, 'dress' => $this->dress, 'appearance' => $this->appearance];
     $profile->save();
     $this->_profile = $profile;
 }
コード例 #2
0
 /**
 * Creates data provider instance with search query applied
 *
 * @param array $params
 *
 * @return ActiveDataProvider
 */
 public function search($params)
 {
     $query = Profile::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'event_id' => $this->event_id, 'age' => $this->age, 'height' => $this->height, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'gender', $this->gender])->andFilterWhere(['like', 'dress', $this->dress])->andFilterWhere(['like', 'appearance', $this->appearance]);
     return $dataProvider;
 }
コード例 #3
0
 /**
  * @return null|Profile
  */
 public function getProfile()
 {
     if (!$this->_profile) {
         $this->_profile = Profile::findOne($this->profile_id);
     }
     return $this->_profile;
 }
コード例 #4
0
 /**
  * Finds the Profile model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Profile the loaded model
  * @throws HttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Profile::findOne($id)) !== null) {
         return $model;
     } else {
         throw new HttpException(404, 'The requested page does not exist.');
     }
 }
コード例 #5
0
ファイル: Event.php プロジェクト: aixiaobenaixiaoben/find
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProfiles()
 {
     return $this->hasMany(\common\models\profile\Profile::className(), ['event_id' => 'id']);
 }