field($field) ->order($order) ->paginate(['list_rows' => $pageSize, 'query' => request()->param()]); $page = $list->render(); $data['list'] = $list->toArray()['data']; $data['count'] = $list->total(); $data['last_page'] = $list->toArray()['last_page']; $data['page'] = $page; return $data; } /** * 获取列表 不分页 */ public static function getAllList($where = [], $field = '*', $order = '', $limit = '0') { $data = self::where($where) ->field($field) ->order($order) ->limit($limit) ->select(); return $data; } /** * 获取单条数据 */ public static function getInfo($where = [], $field = '*') { $data = self::where($where) ->field($field) ->find(); return $data; } /** * 获取类型名称 */ public function getTypeTextAttr($value, $data) { $types = [ 1 => '累计签到', 2 => '每日签到' ]; return isset($data['type']) && isset($types[$data['type']]) ? $types[$data['type']] : '未知'; } /** * 获取当前签到配置关联的所有奖励 */ public function rewards() { return $this->belongsToMany(Reward::class, SignConfigReward::class, 'reward_id', 'sign_config_id'); } }