index.php 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 $dataProvider yii\data\ArrayDataProvider
  10. * @var $model common\models\Category
  11. */
  12. use backend\grid\DateColumn;
  13. use backend\grid\GridView;
  14. use backend\grid\SortColumn;
  15. use backend\widgets\Bar;
  16. use yii\helpers\Url;
  17. use yii\helpers\Html;
  18. use backend\grid\CheckboxColumn;
  19. use backend\grid\ActionColumn;
  20. $this->title = "Category";
  21. $this->params['breadcrumbs'][] = Yii::t('app', 'Category');
  22. ?>
  23. <div class="row">
  24. <div class="col-sm-12">
  25. <div class="ibox">
  26. <?= $this->render('/widgets/_ibox-title') ?>
  27. <div class="ibox-content">
  28. <?= Bar::widget() ?>
  29. <?= GridView::widget([
  30. 'dataProvider' => $dataProvider,
  31. 'columns' => [
  32. [
  33. 'class' => CheckboxColumn::className(),
  34. ],
  35. [
  36. 'attribute' => 'id',
  37. ],
  38. [
  39. 'attribute' => 'name',
  40. 'label' => Yii::t('app', 'Name'),
  41. 'format' => 'html',
  42. 'value' => function ($model, $key, $index, $column) {
  43. return $model['prefix_level_name'];
  44. }
  45. ],
  46. [
  47. 'attribute' => 'alias',
  48. 'label' => Yii::t('app', 'Alias'),
  49. ],
  50. [
  51. 'class' => SortColumn::className(),
  52. 'primaryKey' => function($model){
  53. return ["id" => $model["id"]];
  54. },
  55. 'label' => Yii::t('app', 'Sort')
  56. ],
  57. [
  58. 'class' => DateColumn::className(),
  59. 'label' => Yii::t('app', 'Created At'),
  60. 'attribute' => 'created_at',
  61. ],
  62. [
  63. 'class' => DateColumn::className(),
  64. 'label' => Yii::t('app', 'Updated At'),
  65. 'attribute' => 'updated_at',
  66. ],
  67. [
  68. 'class' => ActionColumn::className(),
  69. 'buttons' => [
  70. 'create' => function ($url, $model, $key) {
  71. return Html::a('<i class="fa fa-plus" aria-hidden="true"></i> ', Url::to([
  72. 'create',
  73. 'parent_id' => $model['id']
  74. ]), [
  75. 'title' => Yii::t('app', 'Create'),
  76. 'data-pjax' => '0',
  77. 'class' => 'btn-sm J_menuItem',
  78. ]);
  79. }
  80. ],
  81. 'template' => '{create} {view-layer} {update} {delete}',
  82. ]
  83. ]
  84. ]) ?>
  85. </div>
  86. </div>
  87. </div>
  88. </div>