Browse Source

feat:修改评论视图界面字段显示

antshop
linyaostalker 5 years ago
parent
commit
5ed04dd2a1
  1. 46
      backend/modules/shop/models/searchs/CommentSearch.php
  2. 21
      backend/modules/shop/views/comment/view.php

46
backend/modules/shop/models/searchs/CommentSearch.php

@ -13,13 +13,13 @@ use backend\modules\shop\models\ars\Comment;
class CommentSearch extends Comment class CommentSearch extends Comment
{ {
/** /**
* @return array
* 增加创建时间查询字段
*/
* @return array
* 增加创建时间查询字段
*/
public function attributes() public function attributes()
{
return ArrayHelper::merge(['created_at_range'], parent::attributes());
}
{
return ArrayHelper::merge(['created_at_range'], parent::attributes());
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -41,14 +41,14 @@ class CommentSearch extends Comment
return Model::scenarios(); return Model::scenarios();
} }
/** /**
* @return array
* 列格式
*/
* @return array
* 列格式
*/
public function columns() public function columns()
{ {
return [ return [
'id',
'user_id',
'id',
'user_id',
[ [
'attribute' => 'order_goods_id', 'attribute' => 'order_goods_id',
'value' => function ($model) { 'value' => function ($model) {
@ -56,8 +56,8 @@ class CommentSearch extends Comment
}, },
'label' => '商品名称' 'label' => '商品名称'
], ],
'star',
'content',
'star',
'content',
[ [
'attribute' => 'status', 'attribute' => 'status',
'value' => function ($model) { 'value' => function ($model) {
@ -65,7 +65,7 @@ class CommentSearch extends Comment
}, },
'label' => '状态' 'label' => '状态'
], ],
'created_at:datetime',
'created_at:datetime',
[ [
'class' => 'iron\grid\ActionColumn', 'class' => 'iron\grid\ActionColumn',
'align' => 'center', 'align' => 'center',
@ -106,10 +106,10 @@ class CommentSearch extends Comment
]; ];
} }
/** /**
* @param $params
* @return ActiveDataProvider
* 不分页的所有数据
*/
* @param $params
* @return ActiveDataProvider
* 不分页的所有数据
*/
public function allData($params) public function allData($params)
{ {
$query = Comment::find(); $query = Comment::find();
@ -151,11 +151,11 @@ class CommentSearch extends Comment
return $this->filter($query, $dataProvider); return $this->filter($query, $dataProvider);
} }
/** /**
* @param $query
* @param $dataProvider
* @return ActiveDataProvider
* 条件筛选
*/
* @param $query
* @param $dataProvider
* @return ActiveDataProvider
* 条件筛选
*/
private function filter($query, $dataProvider){ private function filter($query, $dataProvider){
if (!$this->validate()) { if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails // uncomment the following line if you do not want to return any records when validation fails

21
backend/modules/shop/views/comment/view.php

@ -1,5 +1,6 @@
<?php <?php
use backend\modules\shop\models\ars\Comment;
use yii\helpers\Html; use yii\helpers\Html;
use yii\widgets\DetailView; use yii\widgets\DetailView;
@ -22,12 +23,24 @@ $this->params['breadcrumbs'][] = $this->title;
'attributes' => [ 'attributes' => [
'id', 'id',
'user_id', 'user_id',
'order_goods_id',
[
'attribute' => 'order_goods_id',
'value' => function ($model) {
return $model->orderGoods->goods_name;
},
'label' => '商品名称'
],
'star', 'star',
'content:ntext', 'content:ntext',
'status',
'updated_at',
'created_at',
[
'attribute' => 'status',
'value' => function ($model) {
return Comment::$commentStatus[$model->status];
},
'label' => '状态'
],
'updated_at:datetime',
'created_at:datetime',
], ],
]) ?> ]) ?>

Loading…
Cancel
Save