view.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * Author: lf
  4. * Blog: https://blog.feehi.com
  5. * Email: job@feehi.com
  6. * Created at: 2018-02-24 14:36
  7. */
  8. use common\libs\Constants;
  9. use yii\widgets\DetailView;
  10. /* @var $this yii\web\View */
  11. /* @var $model common\models\FriendlyLink */
  12. ?>
  13. <?= DetailView::widget([
  14. 'model' => $model,
  15. 'attributes' => [
  16. 'id',
  17. 'name',
  18. [
  19. 'attribute' => 'image',
  20. 'format' => 'raw',
  21. 'value' => function($model){
  22. if( empty( $model->image ) ) return '-';
  23. return "<img style='max-width:100px;max-height:100px' src='" . $model->image . "'>";
  24. }
  25. ],
  26. 'url',
  27. [
  28. 'attribute' => 'target',
  29. 'value' => function($model){
  30. return Constants::getTargetOpenMethod($model->target);
  31. }
  32. ],
  33. 'sort',
  34. [
  35. 'attribute' => 'status',
  36. 'value' => function($model){
  37. return Constants::getStatusItems($model->status);
  38. }
  39. ],
  40. 'created_at:datetime',
  41. 'updated_at:datetime',
  42. ],
  43. ]) ?>