Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions app/Filament/Admin/Widgets/StatsOverviewWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace App\Filament\Admin\Widgets;

use App\Models\Beneficiary;
use App\Models\Organization;
use App\Models\Shelter;
use App\Models\Stay;
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;
use Illuminate\Support\Number;
Expand All @@ -32,7 +32,22 @@ protected function getStats(): array

Stat::make(
__('app.stats.overview.beneficiaries'),
Number::format(Beneficiary::count())
Number::format(Stay::count())
),

Stat::make(
__('app.stats.overview.average_capacity'),
Number::format((float) Shelter::avg('capacity'), 0)
),

Stat::make(
__('app.stats.overview.total_capacity'),
Number::format((float) Shelter::sum('capacity'))
),

Stat::make(
__('app.stats.overview.total_occupancy'),
Number::format(Stay::whereCurrent()->count())
),
];
}
Expand Down
3 changes: 3 additions & 0 deletions app/Http/Middleware/SetLocale.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Http\Request;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Number;
use Symfony\Component\HttpFoundation\Response;

class SetLocale
Expand All @@ -25,6 +26,8 @@ public function handle(Request $request, Closure $next): Response
$this->setLocaleForUser($request);
}

Number::useLocale(App::getLocale());

return $next($request);
}

Expand Down
2 changes: 2 additions & 0 deletions bootstrap/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types=1);

use App\Http\Middleware\SetCloudfrontHeaders;
use App\Http\Middleware\SetLocale;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
Expand All @@ -16,6 +17,7 @@
)
->withMiddleware(function (Middleware $middleware) {
$middleware->trustProxies('*')
->appendToGroup('web', SetLocale::class)
->append(SetCloudfrontHeaders::class);
})
->withExceptions(function (Exceptions $exceptions) {
Expand Down
3 changes: 3 additions & 0 deletions lang/en/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@
'beneficiaries' => 'Total hosted beneficiaries',
'organizations' => 'Total organizations',
'shelters' => 'Total shelters',
'average_capacity' => 'Average shelter capacity',
'total_capacity' => 'Total shelter capacity',
'total_occupancy' => 'Total current occupancy',
],
'beneficiaries' => [
'nationalities' => 'Total beneficiaries per nationality',
Expand Down
1 change: 0 additions & 1 deletion resources/views/components/locale-switcher/panel.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
@foreach ($locales as $locale)
<x-filament::dropdown.list.item
:color="$locale->isCurrent() ? 'primary' : null"
2icon="heroicon-m-chevron-right"
:action="route('preferred-locale', ['locale' => $locale->code])"
method="post"
tag="form">
Expand Down
Loading