admin/plugins/decorate/src/models/DecorateFooterModel.php

58 lines
1.3 KiB
PHP

<?php
namespace Yunshop\Decorate\models;
use app\common\models\BaseModel;
class DecorateFooterModel extends BaseModel
{
protected $table = 'yz_decorate_footer';
public $timestamps = true;
protected $guarded = [''];
/**
* 获取列表
* @param int $pageSize
* @param array $wheres
* @param array $field 需要获取的字段 默认全部
* @return object
*/
public static function getList($pageSize=20,$wheres=[],$field='*',$list=true)
{
$res = self::uniacid()->select($field);
if ($wheres['name']) //页面名称
{
$res = $res->where('name', 'like', '%'.$wheres['name'].'%');
}
//页面分类 1.h5 2.小程序
if ($wheres['page_sort'])
{
$res = $res->where('page_sort', '=', $wheres['page_sort']);
}
if ($list) {
return $res->orderBy('created_at','desc')->paginate($pageSize);
} else {
return $res->orderBy('created_at','desc')->first();
}
}
/**
* 字段规则
* @return array
*/
public function rules()
{
return [
'uniacid' => 'required|integer',
// 'page_info' => 'json',
'name' => 'required|string|max:255',
'page_sort' => 'required|integer',
];
}
}