给Nav新增快捷方法

This commit is contained in:
augushong
2020-11-19 15:40:17 +08:00
parent f3f71017df
commit 960c21ccbe

View File

@@ -12,6 +12,8 @@ use think\Model;
class Nav extends Model class Nav extends Model
{ {
protected static $listNav = [];
public static $statusName = [ public static $statusName = [
0 => '不显示', 0 => '不显示',
1 => '显示' 1 => '显示'
@@ -26,4 +28,13 @@ class Nav extends Model
{ {
return self::$statusName[$this->getData('status')]; 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];
}
} }