/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Blocks::find(); // add conditions that should always apply here $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['sortOrder' => SORT_ASC]]]); $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; } // grid filtering conditions $query->andFilterWhere(['id' => $this->id, 'sortOrder' => $this->sortOrder, 'active' => $this->active]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content]); return $dataProvider; }
public function addressbalance($address = null) { $txs = Blocks::find('all', array('conditions' => array('txid.vout.scriptPubKey.addresses' => $address))); $amount = 0; $this->_render['layout'] = false; foreach ($txs as $tx) { foreach ($tx['txid'] as $txid) { if (!$txid['vin']['coinbase']) { if ($txid['vout'] != "") { foreach ($txid['vout'] as $vout) { foreach ($vout['scriptPubKey']['addresses'] as $addresses) { if ($addresses == $address) { $amount = $amount + $vout['value']; } } } } } } } return compact('amount'); }