mirror of https://github.com/1099438829/apeblog
修正后台管理文章搜索问题
This commit is contained in:
parent
ad112e8e5b
commit
d5bcbc3c98
|
|
@ -45,7 +45,7 @@ class Article extends AuthController
|
|||
public function lst()
|
||||
{
|
||||
$where = Util::postMore([
|
||||
['name', ''],
|
||||
['title', ''],
|
||||
['start_time', ''],
|
||||
['end_time', ''],
|
||||
['status', ''],
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@
|
|||
<div class="card-body">
|
||||
<form class="form-inline searchForm" onsubmit="return false;">
|
||||
<div class="form-group">
|
||||
<label for="name">文章标题</label>
|
||||
<label for="title">文章标题</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" id="name" name="name" placeholder="请输入文章标题">
|
||||
<input type="text" class="form-control" id="title" name="title" placeholder="请输入文章标题">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -28,19 +28,17 @@ class Document extends BaseModel
|
|||
public static function systemPage($where): array
|
||||
{
|
||||
$model = new self;
|
||||
$count = self::counts($model);
|
||||
if ($where['title'] != '') $model = $model->where("title", "like", "%$where[title]%");
|
||||
if ($where['start_time'] != '') $model = $model->where("create_time", ">", strtotime($where['start_time'] . " 00:00:00"));
|
||||
if ($where['end_time'] != '') $model = $model->where("create_time", "<", strtotime($where['end_time'] . " 23:59:59"));
|
||||
if ($where['status'] != '') $model = $model->where("status", $where['status']);
|
||||
$model = $model->order("sort desc")->order("id desc");
|
||||
$count = self::counts($model);
|
||||
if ($where['page'] && $where['limit']) $model = $model->page((int)$where['page'], (int)$where['limit']);
|
||||
$data = $model->select();
|
||||
if ($data) $data = $data->toArray();
|
||||
$categoryList = DocumentCategory::where('id', 'in', array_column($data, 'category_id'))->column('title', 'id');
|
||||
foreach ($data as &$item) {
|
||||
if (!empty($categoryList[$item['category_id']])) {
|
||||
$item['category_title'] = $categoryList[$item['category_id']];
|
||||
} else {
|
||||
$item['category_title'] = '';
|
||||
}
|
||||
}
|
||||
$categoryList = DocumentCategory::column('title', 'id');
|
||||
$data = $model->select()->each(function ($item) use($categoryList) {
|
||||
$item->category_title = $categoryList[$item->category_id]??"";
|
||||
});
|
||||
return compact('data', 'count');
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue