You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.6 KiB

<?php
namespace app\feedback\model;
use app\base\model\user\UserInfo;
use think\model\concern\SoftDelete;
class Feedback extends Base
{
use SoftDelete;
protected $type = [
'image_path' => 'serialize',
];
/**
* 获取状态名称
* @date 2021-03-01
*/
public function getStatusTextAttr($value, $data)
{
$status_text = [
1 => '待处理',
2 => '已处理'
];
return $status_text[$data['status']];
}
/**
* 查找全部数据--带分页
* @param array $where 查询条件
* @param string $field 查询字段
* @param string $order 排序方式
* @param int $page 当前页数
* @date 2022-12-22
*/
public function listFeedbackWithPage($where, $page, $field = '*', $order = '')
{
if (empty($order)) {
$order = 'id desc';
}
$data_list = $this->field($field)->where($where)->order($order)
->paginate(['list_rows' => 10, 'page' => $page], false)->each(function ($item){
$item['status_text'] = $item->status_text;
$item['show_create_time'] = date("Y.m.d H:i", $item->getData('create_time'));
unset($item['create_time']);
});
return $data_list;
}
/**
* 用户信息
* @return $this
*/
public function userInfo()
{
return $this->hasOne(UserInfo::class,'user_id','user_id')->bind(['nick_name']);
}
/**
* 分类信息
*/
public function feedbackCategory()
{
return $this->hasOne('FeedbackCategory','id','category_id')->bind(['category_name']);
}
}