From 960c21ccbe9b91178db484e6bddee83cfaef9a65 Mon Sep 17 00:00:00 2001 From: augushong Date: Thu, 19 Nov 2020 15:40:17 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=99Nav=E6=96=B0=E5=A2=9E=E5=BF=AB?= =?UTF-8?q?=E6=8D=B7=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/model/Nav.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/app/model/Nav.php b/app/model/Nav.php index fbea981..22e8cd8 100644 --- a/app/model/Nav.php +++ b/app/model/Nav.php @@ -12,18 +12,29 @@ use think\Model; class Nav extends Model { + protected static $listNav = []; + public static $statusName = [ - 0=>'不显示', - 1=>'显示' + 0 => '不显示', + 1 => '显示' ]; // public function getImgAttr($value) { - return get_source_link($value,'/static/images/noimg.png'); + return get_source_link($value, '/static/images/noimg.png'); } public function getStatusNameAttr() { return self::$statusName[$this->getData('status')]; } + + public static function getListNav($type = 1) + { + + if (!isset(self::$listNav[$type])) { + self::$listNav[$type] = Nav::where('type', $type)->where('status', 1)->order('sort asc')->select(); + } + return self::$listNav[$type]; + } }