/**
  * @inheritdoc
  */
 public function afterDelete()
 {
     parent::afterDelete();
     $currencies = Currency::findAll();
     /** @var Currency $currency */
     foreach ($currencies as $currency) {
         if ($this->name == $currency->currency_rate_provider_name) {
             $currency->currency_rate_provider_name = null;
             $currency->save();
         }
     }
 }
 /**
  * Finds Currency by ISO code. Return Currency[] if $all == true
  * if $all == false returns only first of found Currency
  * If there are no Currency with given code can return MainCurrency or null, depends on $useMainCurrency
  *
  * @param string $code
  * @param bool $useMainCurrency
  * @param bool $all
  * @return Currency|Currency[]|null
  */
 public static function findCurrencyByIso($code, $useMainCurrency = false, $all = false)
 {
     $currencies = Currency::findAll();
     $currencies = array_filter($currencies, function ($e) use($code) {
         /** @var  Currency $e */
         return $code == $e->iso_code;
     });
     $out = null;
     if (false === empty($currencies)) {
         if (true === $all) {
             $out = $currencies;
         } else {
             $out = array_shift($currencies);
         }
     } else {
         if (true === $useMainCurrency) {
             $out = static::getMainCurrency();
         } else {
             $out = null;
         }
     }
     return $out;
 }
<?php

use DotPlant\Currencies\CurrenciesModule;
use DotPlant\Currencies\models\Currency;
use DevGroup\AdminUtils\Helper;
use yii\grid\GridView;
use kartik\icons\Icon;
use yii\helpers\Html;
$currencies = CurrenciesModule::module()->getData(Currency::className());
$currenciesProvider = new \yii\data\ArrayDataProvider(['allModels' => Currency::findAll(), 'pagination' => ['pageSize' => 10]]);
$currencyButtons = Html::tag('div', Html::a(Icon::show('plus') . '&nbsp;' . Yii::t('dotplant.currencies', 'Add currency'), ['/currencies/currencies-manage/edit', 'returnUrl' => Helper::returnUrl()], ['role' => 'button', 'class' => 'btn btn-success']) . Html::a(Icon::show('eraser') . '&nbsp;' . Yii::t('dotplant.currencies', 'Reset currencies'), ['/currencies/currencies-manage/reset', 'returnUrl' => Helper::returnUrl()], ['role' => 'button', 'class' => 'btn btn-danger']), ['class' => 'btn-group pull-right', 'role' => 'group', 'aria-label' => 'Currencies buttons']);
$gridTpl = <<<TPL
<div class="box-body">
    {items}
</div>
<div class="box-footer">
    <div class="row ext-bottom">
        <div class="col-sm-5">
            {summary}
        </div>
        <div class="col-sm-7">
            {pager}
        </div>
    </div>
    <div class="row">
        <div class="col-sm-12">[button]</div>
    </div>
</div>
TPL;
echo GridView::widget(['id' => 'dotplant-currencies-list', 'dataProvider' => $currenciesProvider, 'layout' => str_replace('[button]', $currencyButtons, $gridTpl), 'tableOptions' => ['class' => 'table table-bordered table-hover table-responsive'], 'columns' => ['name', 'iso_code', ['attribute' => 'is_main', 'content' => function ($data) {
    return Yii::$app->formatter->asBoolean($data->is_main);