Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Damage::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 public function actionDamage($q = null, $id = null)
 {
     \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     if (is_null($q)) {
         $q = "";
     }
     $out = ['results' => []];
     $jobs = Damage::find()->where('name LIKE :q')->params([':q' => '%' . $q . '%'])->asArray()->all();
     foreach ($jobs as $job) {
         $out['results'][] = ['id' => $job['id'], 'text' => $job['name']];
     }
     return $out;
 }
Ejemplo n.º 3
0
 /**
  * Finds the Damage model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Damage the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Damage::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 4
0
 public function actionStep1()
 {
     Yii::$app->session['carPartTotal'] = 0.0;
     $carPart = new CarPart();
     $sizes = ArrayHelper::map(Size::find()->asArray()->all(), 'id', 'name');
     $colors = ArrayHelper::map(Color::find()->asArray()->all(), 'id', 'name');
     $damages = ArrayHelper::map(Damage::find()->asArray()->all(), 'id', 'name');
     return $this->render('step1', ['carPart' => $carPart, 'sizes' => $sizes, 'colors' => $colors, 'damages' => $damages]);
 }
Ejemplo n.º 5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getDamage()
 {
     return $this->hasOne(Damage::className(), ['id' => 'damage_id']);
 }