index.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. /**
  3. * Author: lf
  4. * Blog: https://blog.feehi.com
  5. * Email: job@feehi.com
  6. * Created at: 2016-03-21 14:14
  7. */
  8. /**
  9. * @var $this yii\web\View
  10. * @var $dataProvider yii\data\ArrayDataProvider
  11. * @var $searchModel backend\models\search\MenuSearch
  12. */
  13. use backend\grid\DateColumn;
  14. use backend\grid\GridView;
  15. use backend\grid\SortColumn;
  16. use backend\grid\StatusColumn;
  17. use common\models\Menu;
  18. use backend\widgets\Bar;
  19. use common\libs\Constants;
  20. use yii\helpers\Html;
  21. use yii\helpers\Url;
  22. use backend\grid\CheckboxColumn;
  23. use backend\grid\ActionColumn;
  24. $this->title = "Backend Menus";
  25. $this->params['breadcrumbs'][] = Yii::t('app', 'Backend Menus');
  26. ?>
  27. <div class="row">
  28. <div class="col-sm-12">
  29. <div class="ibox">
  30. <?= $this->render('/widgets/_ibox-title') ?>
  31. <div class="ibox-content">
  32. <?= Bar::widget() ?>
  33. <?= GridView::widget([
  34. 'dataProvider' => $dataProvider,
  35. 'filterModel' => $searchModel,
  36. 'layout' => '{items}',
  37. 'columns' => [
  38. [
  39. 'class' => CheckboxColumn::className(),
  40. ],
  41. [
  42. 'attribute' => 'name',
  43. 'label' => Yii::t('app', 'Name'),
  44. 'format' => 'html',
  45. 'value' => function ($model, $key, $index, $column) {
  46. return $model['prefix_level_name'];
  47. }
  48. ],
  49. [
  50. 'attribute' => 'icon',
  51. 'label' => Yii::t('app', 'Icon'),
  52. 'format' => 'html',
  53. 'value' => function ($model) {
  54. return "<i class='fa {$model['icon']}'></i>";
  55. }
  56. ],
  57. [
  58. 'attribute' => 'url',
  59. 'label' => Yii::t('app', 'Url'),
  60. 'value' => function($model){
  61. /** @var Menu $mddel */
  62. return $model->convertJSONStringToRelativeUrl();
  63. }
  64. ],
  65. [
  66. 'class' => SortColumn::className(),
  67. 'primaryKey' => function($model){
  68. return ["id" => $model["id"]];
  69. },
  70. 'label' => Yii::t('app', 'Sort')
  71. ],
  72. [
  73. 'class' => StatusColumn::className(),
  74. 'attribute' => 'is_display',
  75. 'formName' => (new Menu)->formName() . '[is_display]',
  76. 'label' => Yii::t('app', 'Is Display'),
  77. 'filter' => Constants::getYesNoItems()
  78. ],
  79. [
  80. 'class' => DateColumn::className(),
  81. 'attribute' => 'created_at',
  82. 'label' => Yii::t('app', 'Created At'),
  83. ],
  84. [
  85. 'class' => DateColumn::className(),
  86. 'attribute' => 'updated_at',
  87. 'label' => Yii::t('app', 'Updated At'),
  88. ],
  89. [
  90. 'class' => ActionColumn::className(),
  91. 'width' => '190px',
  92. 'buttons' => [
  93. 'create' => function ($url, $model, $key) {
  94. return Html::a('<i class="fa fa-plus" aria-hidden="true"></i> ', Url::to([
  95. 'create',
  96. 'parent_id' => $model['id']
  97. ]), [
  98. 'title' => Yii::t('app', 'Create'),
  99. 'data-pjax' => '0',
  100. 'class' => 'btn-sm J_menuItem',
  101. ]);
  102. }
  103. ],
  104. 'template' => '{create} {view-layer} {update} {delete}',
  105. ]
  106. ]
  107. ]) ?>
  108. </div>
  109. </div>
  110. </div>
  111. </div>