'json', 'gift' => 'json' ]; public static $timeMap = [ self::TIME_YEAR => '年', self::TIME_MONTH => '月', self::TIME_DAY => '天', ]; public static $statusMap = [ self::STATUS_ENABLE => '可用', self::STATUS_DISABLE => '不可用' ]; protected static function booted() { static::addGlobalScope('sort', function (Builder $builder) { $builder->orderBy('sort', 'asc'); }); } public function users() { return $this->belongsToMany(User::class, 'user_vips', 'vip_id', 'user_id'); } public function hasUser() { return $this->users()->exists(); } }