qingjian/app/model/Gift.php

49 lines
1.2 KiB
PHP
Raw Permalink Normal View History

2021-08-06 10:50:55 +00:00
<?php
namespace app\model;
//礼物
class Gift extends Base
{
protected $autoWriteTimestamp = true;
public static function onAfterInsert($item)
{
$item->sort = $item->id;
$item->save();
}
/**
* 获取文章列表
* @param $categoryId 分类ID
* @param int $per 每页数量
* @param string $keyword 关键词
* @param array $param 文章类型:置顶、热门、推荐 ['top','hot','recommend']
* @param int $status 文章状态,-1表示不限制
* @return \think\Paginator
* @throws \think\db\exception\DbException
*/
public static function getList( $per = 20, $keyword = '')
{
$whereMap = [];
$pageParam = [];
if (!empty($keyword)) {
$whereMap[] = ['title', 'like', '%' . $keyword . '%'];
$pageParam['keyword'] = $keyword;
}
$paginate = [
'list_rows' => $per,
'query' => $pageParam
];
return self::when(count($whereMap) > 0, function ($query) use ($whereMap) {
$query->where($whereMap);
})
->order("sort desc")
->paginate($paginate, false);
}
// ----------页面函数
}