Advertisement
pmtpenza22

Untitled

Feb 18th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. <?php
  2.  
  3. use yii\helpers\Html;
  4. use yii\grid\GridView;
  5. use backend\models\Cat;
  6. use yii\web\NotFoundHttpException;
  7. use yii\web\Controller;
  8. use yii\helpers\FileHelper;
  9. use yii\helpers\Url;
  10. use yii\web\UploadedFile;
  11. use yii\helpers\VarDumper;
  12. use yii\helpers\ArrayHelper;
  13. use backend\models\ImagesManager;
  14. use backend\models\Product;
  15.  
  16.  
  17. /* @var $this yii\web\View */
  18. /* @var $searchModel backend\models\ProductSearch */
  19. /* @var $dataProvider yii\data\ActiveDataProvider */
  20.  
  21. $this->title = 'Товары';
  22. $this->params['breadcrumbs'][] = $this->title;
  23. ?>
  24. <div class="product-index">
  25.  
  26. <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
  27.  
  28. <p>
  29. <?= Html::a('Добавить товар', ['create'], ['class' => 'btn btn-success']) ?>
  30. </p>
  31.  
  32. <?= GridView::widget([
  33. 'dataProvider' => $dataProvider,
  34. 'filterModel' => $searchModel,
  35. 'columns' => [
  36. ['class' => 'yii\grid\SerialColumn'],
  37.  
  38. //'id',
  39. 'name',
  40. [
  41. 'attribute'=>'status',
  42. 'value' => function($data){
  43. return $data->status ? 'Активен' : 'Блокированный';
  44. }
  45. ],
  46. //'status',
  47. //'description',
  48. 'price_roz',
  49. 'price_opt',
  50. //'hit',
  51. //'new',
  52. // 'sale',
  53. //'category_id',
  54. [
  55. 'attribute'=>'category_id',
  56. 'value'=>function($data){
  57. return $data->category->name;
  58. },
  59. ],
  60. [
  61. 'attribute'=>'hit',
  62. 'format' => 'raw',
  63. 'value'=>function($data){
  64. return !$data->hit ? '<span class="text-success">Нет</span>' : '<span class="text-danger">Да</span>';
  65. },
  66. ],
  67. [
  68. 'attribute'=>'new',
  69. 'format' => 'raw',
  70. 'value'=>function($data){
  71. return !$data->new ? '<span class="text-success">Нет</span>' : '<span class="text-danger">Да</span>';
  72. },
  73. ],
  74. [
  75. 'attribute'=>'sale',
  76. 'format' => 'raw',
  77. 'value'=>function($data){
  78. return !$data->sale ? '<span class="text-success">Нет</span>' : '<span class="text-danger">Да</span>';
  79. },
  80. ],
  81. //'meta_title',
  82. //'meta_keyword',
  83. //'meta_description',
  84.  
  85. ['class' => 'yii\grid\ActionColumn'],
  86. ],
  87. ]); ?>
  88. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement