Пример #1
0
 /**
  * Sends an email to the specified email address using the information collected by this model.
  * @param  string  $email the target email address
  * @return boolean whether the model passes validation
  */
 public function create()
 {
     if ($this->validate()) {
         $model = new Lines();
         $model->name = $this->name;
         $model->image = $this->image;
         $model->description = $this->description;
         $model->start_time = $this->start_time;
         $model->end_time = $this->end_time;
         $model->save();
         return $model->id;
     } else {
         return false;
     }
 }
Пример #2
0
 public function actionDelete($id)
 {
     $model = Lines::findOne($id);
     if (!empty($model)) {
         $model->record_status = STATUS_DELETED;
         if ($model->save()) {
             return $this->redirect('../../line/index');
         }
     }
 }
Пример #3
0
 public function actionCreate($id = null)
 {
     $lstLine = Lines::find()->where([RECORD_STATUS => STATUS_NORMAL])->all();
     $model = new Stations();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate()) {
             $model->save();
             $id = $model->id;
             $model->file = UploadedFile::getInstance($model, 'file');
             if ($model->file) {
                 $id = $model->id;
                 $imageName = "station_" . $id . '_' . getdate()[0];
                 $model->file->saveAs('uploads/' . $imageName . '.' . $model->file->extension);
                 $station = Stations::findOne($id);
                 $station->image = '@web/uploads/' . $imageName . '.' . $model->file->extension;
                 $station->save();
             }
             return $this->redirect(['station/index']);
         }
     } else {
         return $this->render('create', ['model' => $model, 'listLine' => $lstLine, 'currentLine' => $id]);
     }
 }
Пример #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getLine()
 {
     return $this->hasOne(Lines::className(), ['id' => 'line_id']);
 }