2023-03-03 19:00:46 +08:00

54 lines
1.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* 商户菜单 model
*
* @author刘孝全
* @emailq8197264@126.com
* @date 2023年03月3日
*/
declare (strict_types = 1);
namespace app\admin\model\system\auth;
use think\Model;
/**
* Class Menu
*/
class Menu extends Model
{
// 指定连接到商城库
protected $connection = 'shop';
// 指定此model关联表
protected $table = 'eb_system_menu';
/**
* 按条件获取商户菜单数据
*
* @param array $where 过滤字段条件
* @param int $is_mer 菜单类型: 0商城平台菜单 1商户菜单
*
* @return array
*/
function Search(array $where=[], int $is_mer=2):array
{
// 按条件 拼接 select 前sql
$query = self::where('is_mer', $is_mer)->order('sort DESC,menu_id ASC');
if (isset($where['pid'])) $query->where('pid', (int)$where['pid']);
if (isset($where['keyword'])) $query->whereLike('menu_name|route', "%{$where['keyword']}%");
if (isset($where['is_menu'])) $query->where('is_menu', (int)$where['is_menu']);
// 查询记录总行数
// $count = $query->count();
// 隐藏指定字段
$list = $query->hidden(['update_time', 'path'])->select()->toArray();
// 合并为一个数组并返回
// compact('count', 'list');
return $list;
}
}