View file app/Controllers/OnlineController.php

File size: 969B
<?php

declare(strict_types=1);

namespace App\Controllers;

use App\Models\Online;

class OnlineController extends BaseController
{
    /**
     * Главная страница
     */
    public function index()
    {
        $other  = Online::query()->count();
        $guests = false;

        $online = Online::query()
            ->whereNotNull('user_id')
            ->with('user')
            ->orderByDesc('updated_at')
            ->paginate(setting('onlinelist'));

        return view('pages/online', compact('online', 'other', 'guests'));
    }

    /**
     * Список всех пользователей
     */
    public function all()
    {
        $other  = Online::query()->whereNotNull('user_id')->count();
        $guests = true;

        $online = Online::with('user')
            ->orderByDesc('updated_at')
            ->paginate(setting('onlinelist'));

        return view('pages/online', compact('online', 'other', 'guests'));
    }
}