Browse Source

优化车位类型更新2

master
wanghongjun 6 days ago
parent
commit
f484285488
  1. 16
      app/Models/ParkingSpaceType.php

16
app/Models/ParkingSpaceType.php

@ -25,6 +25,7 @@ class ParkingSpaceType extends Model
'attr_color_occupy', 'attr_color_occupy',
'attr_color_vacant', 'attr_color_vacant',
'attr_color_warning', 'attr_color_warning',
'attr_is_warning',
'attr_is_flicker' 'attr_is_flicker'
]; ];
protected $hidden protected $hidden
@ -43,4 +44,19 @@ class ParkingSpaceType extends Model
{ {
return self::query()->select(['id', 'name'])->get()->toArray(); return self::query()->select(['id', 'name'])->get()->toArray();
} }
// 获取默认车位类型
public static function getDefaultData()
{
$res = self::query()->where('is_default', 1)->first(['id', 'name']);
if ($res) {
return $res;
} else {
$res = self::query()->first(['id', 'name']);
if ($res) {
return $res;
}
}
return [];
}
} }

Loading…
Cancel
Save