index.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. use app\models\Person;
  3. use yii\helpers\Html;
  4. use yii\helpers\Url;
  5. use yii\grid\ActionColumn;
  6. use yii\grid\GridView;
  7. /** @var yii\web\View $this */
  8. /** @var yii\data\ActiveDataProvider $dataProvider */
  9. $this->title = 'Персоны (Эксперты)';
  10. $this->params['breadcrumbs'][] = $this->title;
  11. ?>
  12. <div class="person-index">
  13. <p>
  14. <?= Html::a('Создать карточку персоны', ['create'], ['class' => 'btn btn-success']) ?>
  15. </p>
  16. <?= GridView::widget([
  17. 'dataProvider' => $dataProvider,
  18. 'columns' => [
  19. ['class' => 'yii\grid\SerialColumn'],
  20. [
  21. 'attribute' => 'Фото',
  22. 'value' => function ($model) {
  23. return '<img class="profile-user-img img-circle" style="width:64px;height:64px;object-fit:cover;-o-object-fit:cover;" src="'.$model->getImg('4','jpg').'">';
  24. },
  25. 'format' => 'raw',
  26. ],
  27. 'name:text',
  28. [
  29. 'attribute' => 'alias',
  30. 'value' => function ($model) {
  31. return Url::base('https').'/person/'.$model->alias;
  32. },
  33. 'format' => 'url',
  34. ],
  35. 'jobtitle:ntext',
  36. 'birthdate:date',
  37. 'phone:ntext',
  38. 'email:email',
  39. 'show:ntext',
  40. //'id',
  41. [
  42. 'class' => ActionColumn::className(),
  43. 'visibleButtons' =>[
  44. 'delete' => Yii::$app->user->can('admin'),
  45. ],
  46. 'buttonOptions' => ['class' => 'btn btn-default'],
  47. 'urlCreator' => function ($action, Person $model, $key, $index, $column) {
  48. return Url::toRoute([$action, 'id' => $model->id]);
  49. }
  50. ],
  51. ],
  52. ]); ?>
  53. </div>