user()?->isAdmin(), 403); return view('admin.world.index', [ 'metrics' => $this->metrics(), ]); } /** * JSON metrics (also used by the report command). */ public function metrics(): array { return [ 'users' => [ 'total' => User::query()->count(), 'pending' => User::query()->where('status', User::STATUS_PENDING)->count(), 'active' => User::query()->where('status', User::STATUS_ACTIVE)->count(), 'banned' => User::query()->where('status', User::STATUS_BANNED)->count(), 'consents' => UserConsent::query()->count(), ], 'cities' => City::query()->count(), 'characters' => [ 'total' => Character::query()->count(), 'online' => Character::query()->where('is_online', true)->count(), 'hospitalized' => Character::query()->where('state', Character::STATE_HOSPITAL)->count(), 'avg_health' => (int) round(Character::query()->avg('health') ?? 0), 'avg_education' => (int) round(Character::query()->avg('education') ?? 0), 'total_money' => round((float) Character::query()->sum('money'), 2), ], 'world' => [ 'stores' => Store::query()->count(), 'buildings' => Building::query()->count(), 'houses_complete' => Building::query()->where('type', 'house')->where('is_complete', true)->count(), 'jobs' => Job::query()->count(), 'messages' => CharacterMessage::query()->count(), 'transactions' => Transaction::query()->count(), 'transaction_volume' => round((float) Transaction::query()->sum('amount'), 2), ], 'market' => [ 'listings' => MarketListing::query()->where('is_active', true)->count(), ], 'missions' => [ 'active' => Mission::query()->where('is_active', true)->count(), 'completed' => DB::table('character_missions')->where('is_completed', true)->count(), ], ]; } }