<?php namespace app\model; use think\Env; class AuthRoleModel extends BaseModel { protected $name = 'auth_role'; const STATUS_ON = 1; // 用户启用状态 const STATUS_FORBID = 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(); } }