Exemplo 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;
 }
Exemplo 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;
 }
Exemplo n.º 3
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]);
 }