DiverseYouthNightSchool/application/admin/controller/xilufitness/user/Comment.php

99 lines
2.8 KiB
PHP
Raw Normal View History

2024-11-04 10:49:10 +08:00
<?php
namespace app\admin\controller\xilufitness\user;
use app\admin\controller\xilufitness\traits\Fitness;
use app\common\controller\Backend;
use think\exception\DbException;
use think\response\Json;
/**
* 用户评论
*
* @icon fa fa-circle-o
*/
class Comment extends Backend
{
use Fitness;
/**
* Comment模型对象
* @var \app\admin\model\xilufitness\user\Comment
*/
protected $model = null;
protected $relationSearch = true;
protected $searchFields = 'user.nickname,brand.brand_name,shop.shop_name,coach.coach_name';
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\xilufitness\user\Comment;
$this->view->assign("statusList", $this->model->getStatusList());
}
/**
* 查看
*
* @return string|Json
* @throws \think\Exception
* @throws DbException
*/
public function index()
{
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if (false === $this->request->isAjax()) {
$this->assignconfig('user_id',$this->request->param('user_id/d',0));
return $this->view->fetch();
}
//如果发送的来源是 Selectpage则转发到 Selectpage
if ($this->request->request('keyField')) {
return $this->selectpage();
}
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
$fitness_brand_id = $this->getFitnessBrandId();
$fitness_shop_id = $this->getFitnessShopId();
$list = $this->model
->with(['user' => function($query){
$query->withField(['nickname']);
}, 'brand' => function($query){
$query->withField(['brand_name']);
}, 'shop' => function($query){
$query->withField(['shop_name']);
}, 'coach' => function($query){
$query->withField(['coach_name']);
}])
->where($where)
->where(function ($query) use($fitness_brand_id,$fitness_shop_id){
if($fitness_brand_id > 0){
$query->where('comment.brand_id','eq',$fitness_brand_id);
}
if($fitness_shop_id > 0){
$query->where('comment.shop_id','eq',$fitness_shop_id);
}
})
->order($sort, $order)
->paginate($limit);
$result = ['total' => $list->total(), 'rows' => $list->items()];
return json($result);
}
//添加
public function add(){
return;
}
//回收站列表
public function recyclebin() {
return;
}
//回收站(真实删除或清空)
public function destroy($ids = null) {
return;
}
//回收站还原
public function restore($ids = null) {
return;
}
}