예제 #1
0
 /**
  * Lists all Invoice models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new InvoiceSearch();
     $invoice = Invoice::find(1)->one();
     echo '<pre>';
     print_r($invoice->getItems()->asArray()->all());
     echo '</pre>';
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
예제 #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Invoice::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, 'invoice_time' => $this->invoice_time, 'subtotal' => $this->subtotal, 'customer_id' => $this->customer_id]);
     $query->andFilterWhere(['like', 'invoice_number', $this->invoice_number])->andFilterWhere(['like', 'comment', $this->comment])->andFilterWhere(['like', 'attribute1', $this->attribute1]);
     return $dataProvider;
 }