* @return \think\model\relation\HasMany */ public function icons() { return $this->hasMany('IconList', 'icon_id')->field('title,class,code'); } /** * 获取图标css链接 * @author 蔡伟明 <314013107@qq.com> * @return array|string|\think\Collection * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public static function getUrls() { $list = self::where('status', 1)->select(); $list = $list->toArray(); if ($list) { foreach ($list as $key => $item) { $url = substr($item['url'], 0, 4) == 'http' ? $item['url'] : 'http:'.$item['url']; // 检查图标url是否合法 $result = check_icon_url($url); if (true !== $result) { unset($list[$key]); continue; } if (isset($item['icons'])) { $html = ''; } else { $html = '

暂无图标

'; } $list[$key]['html'] = $html; } } return array_values($list); } }