$config = [
...
'bootstrap' => [
\app\components\user\AccessManager::class
],
namespace app\components\user;
use yii\base\Component;
use Yii;
class AccessManager extends Component
{
const ERROR_PAGE = 'site/error';
public function init()
{
if (isset(Yii::$app->user) && !Yii::$app->user->isGuest) {
$this->filtering();
}
}
protected function filtering()
{
$user = Yii::$app->user->identity;
$allowedIps = $user->getAllowedIps();
if (!in_array(Yii::$app->request->getUserIP(), $allowedIps)) {
Yii::$app->catchAll = [self::ERROR_PAGE];
}
}
}
'buttons' => [
'view' => function ($url, $model) {
return Html::a(
'<i class="far fa-eye"></i>',
"#",
[
'data-toggle' => 'modal',
'data-target' => '#viewSupplier-' . $model->id,
'title' => 'View',
'aria-label' => 'View',
'data-pjax' => '0',
'class' => 'btn btn-dark btn-sm text-white'
]);
}
<?php foreach ($dataProvider->models as $model) { ?>
<div class="modal fade" id="viewSupplier-<?= $model->id ?>" tabindex="-1" role="dialog"