Ejemplo n.º 1
0
 /**
  * @param array $row
  */
 private function exportToDb($row)
 {
     if (isset($this->children[(int) $row[2]])) {
         return;
     }
     Child::create(['fio' => $row[0], 'card_number' => $row[2]]);
 }
Ejemplo n.º 2
0
 /**
  * Finds the Child model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Child the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Child::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getChild()
 {
     return $this->hasOne(Child::className(), ['child_id' => 'child_id']);
 }
Ejemplo n.º 4
0
 private function exportToDb(array $row)
 {
     Child::create(['fio' => $row[0], 'card_number' => $row[2]]);
 }
Ejemplo n.º 5
0
 /**
  * @param $cardNumber
  * @return Child
  */
 public function getChildByCardNumber($cardNumber)
 {
     return Child::where('card_number', $cardNumber)->first();
 }
 private function createChild()
 {
     return \App\Models\Child::create(['fio' => 'Ребенок Иванова ' . rand(1, 10000), 'class' => rand(1, 11), 'class_char' => 'A', 'card_number' => rand(1000, 99999), 'city' => 'Кемерово', 'school_number' => rand(10, 100)]);
 }
Ejemplo n.º 7
0
 public function postDelete($id)
 {
     $child = Child::findOrFail($id);
     $child->delete();
     return redirect()->action('ChildrenController@getIndex')->with('flash_message', 'Ребенок удален');
 }