<?php namespace app\model; use think\Env; class AuthRuleModel extends BaseModel { protected $name = 'auth_menu'; const STATUS_ON = 1; // 用户启用状态 const STATUS_FORBID = 2; // 用户禁用状态 const SHOW_ON = 1; // 显示 const SHOW_OFF = 2; // 隐藏 /** * @desc 根据id 查询指定字段 * @param $fields * @param $userId * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public static function getFieldsById($fields, $id): array { $self = self::where('id', $id)->field($fields)->find(); if(empty($self)){ return []; } return $self->toArray(); } }