qingjian/app/model/HallLayout.php

48 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2021-08-06 10:50:55 +00:00
<?php
namespace app\model;
//大厅布局
class HallLayout extends Base
{
protected $autoWriteTimestamp = true;
public static function onAfterInsert($item)
{
$item->sort = $item->id;
$item->save();
}
/**
* 获取列表
* @param int $per 每页数量
* @param string $keyword 关键词
* @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);
}
public static function getAll(){
return self::select()->toArray();
}
}