<?php
namespace app\admin\controller;
use app\common\controller\Backend;
class Forum extends Backend
{
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\Forum;
$this->view->assign("typeList", $this->model->getTypeList());
$this->view->assign("statusList", $this->model->getStatusList());
$this->view->assign("stateList", $this->model->getStateList());
}
public function index()
{
$this->relationSearch = true;
$this->request->filter(['strip_tags']);
if ($this->request->isAjax())
{
if ($this->request->request('keyField'))
{
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$total = $this->model
->with(['user','useragain'])
->where($where)
->order($sort, $order)
->count();
$list = $this->model
->with(['user','useragain'])
->where($where)
->order($sort, $order)
->limit($offset, $limit)
->select();
foreach ($list as $row) {
$row->getRelation('user')->visible(['username']);
$row->getRelation('useragain')->visible(['username']);
}
$list = collection($list)->toArray();
$result = array("total" => $total, "rows" => $list);
return json($result);
}
return $this->view->fetch();
}
}