🆙 More fixes 🆙

This commit is contained in:
Remco
2026-01-20 17:48:16 +01:00
parent 5b3645abba
commit 9a8fa8b1ff
7 changed files with 55 additions and 42 deletions
@@ -49,7 +49,8 @@ class CommandLogResource extends Resource
->badge()
->color(fn (string $state): string => match ($state) {
'yes' => 'primary',
'no' => 'warning'
'no' => 'warning',
default => 'danger',
})
->label(__('filament::resources.columns.success'))
->formatStateUsing(fn (string $state): string => __("filament::resources.options.{$state}")),
@@ -5,17 +5,4 @@ namespace App\Filament\Resources\Hotel;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Collection;
class CustomQueryBuilder extends Builder
{
public function __construct()
{
// Call the parent constructor with a dummy query
parent::__construct(app('db')->query());
}
#[\Override]
public function get($columns = ['*']): Collection
{
return collect(); // Return an empty collection
}
}
class CustomQueryBuilder extends Builder {}
@@ -89,7 +89,9 @@ class BanResource extends Resource
->label(__('filament::resources.columns.reason'))
->tooltip(function (TextColumn $column): ?string {
$state = $column->getState();
if (! is_string($state)) {
return null;
}
if (strlen($state) <= $column->getCharacterLimit()) {
return null;
}
@@ -107,12 +109,14 @@ class BanResource extends Resource
'ip' => __('filament::resources.common.IP'),
'machine' => __('filament::resources.common.Machine'),
'super' => __('filament::resources.common.Super'),
default => __('filament::resources.common.Unknown'),
})
->color(fn (string $state): string => match ($state) {
'account' => 'primary',
'ip' => 'success',
'machine' => 'primary',
'super' => 'danger',
default => 'warning',
}),
TextColumn::make('timestamp')
@@ -121,7 +125,10 @@ class BanResource extends Resource
TextColumn::make('ban_expire')
->label(__('filament::resources.columns.expires_at'))
->formatStateUsing(fn (string $state): string => $state == 0 ? __('filament::resources.common.Never') : date('Y-m-d H:i', $state)),
->formatStateUsing(function (string $state): string {
$ts = is_numeric($state) ? (int) $state : 0;
return $ts === 0 ? __('filament::resources.common.Never') : date('Y-m-d H:i', $ts);
}),
])
->filters([
//
@@ -2,10 +2,9 @@
namespace App\Filament\Resources\User\Users\Pages;
use App\Enums\NotificationType;
use App\Filament\Resources\User\Users\UserResource;
use App\Models\User;
use App\Models\User\UserNotification;
use Illuminate\Support\Facades\DB;
use Filament\Actions\Action;
use Filament\Actions\CreateAction;
use Filament\Forms\Components\Select;
@@ -49,27 +48,32 @@ class ListUsers extends ListRecords
->default(false),
])
->action(function (array $data): void {
$notifications = collect();
$allUsersId = collect($data['users'])->values();
$senderId = $data['as_staff'] ? null : auth()->id();
$allUsersId = collect($data['users'] ?? [])->values();
$senderId = !empty($data['as_staff']) ? null : auth()->id();
if ($allUsersId->isEmpty()) {
$allUsersId = User::select('id')->get()->pluck('id');
}
$allUsersId->each(function ($userId) use ($senderId, $data, $notifications): void {
$notifications->push([
$rows = [];
$message = is_string($data['message'] ?? null) ? $data['message'] : '';
$url = is_string($data['url'] ?? null) ? $data['url'] : null;
$now = now();
$type = 'housekeeping_custom_message';
$allUsersId->each(function ($userId) use ($senderId, $message, $url, $now, $type, &$rows): void {
$rows[] = [
'sender_id' => $senderId,
'recipient_id' => $userId,
'type' => NotificationType::HousekeepingCustomMessage,
'message' => $data['message'],
'url' => $data['url'] ?? null,
'created_at' => now(),
'updated_at' => now(),
]);
'recipient_id' => is_numeric($userId) ? (int) $userId : null,
'type' => $type,
'message' => $message,
'url' => $url,
'created_at' => $now,
'updated_at' => $now,
];
});
UserNotification::insert($notifications->toArray());
if (! empty($rows)) {
DB::table('user_notifications')->insert($rows);
}
Notification::make()
->body(__('Notification sent successfully.'))
+14 -9
View File
@@ -276,23 +276,28 @@ class RconService
$this->closeConnection();
}
public function sendSafelyFromDashboard(string $action, array $args, string $errorMessage): void
public function sendSafelyFromDashboard(string $action, mixed $args, string $errorMessage): void
{
$argsArr = is_array($args) ? $args : [];
try {
switch ($action) {
case 'sendBadge':
/** @var \App\Models\User $user */
$user = $args[0];
/** @var string $badge */
$badge = (string) ($args[1] ?? '');
$userArg = $argsArr[0] ?? null;
if (! ($userArg instanceof \App\Models\User)) {
break;
}
$user = $userArg;
$badge = is_string($argsArr[1] ?? null) ? $argsArr[1] : '';
$this->giveBadge($user, $badge);
break;
case 'removeBadge':
// No direct RCON command defined for removing badges; use alert for now
/** @var \App\Models\User $user */
$user = $args[0];
/** @var string $badge */
$badge = (string) ($args[1] ?? '');
$userArg = $argsArr[0] ?? null;
if (! ($userArg instanceof \App\Models\User)) {
break;
}
$user = $userArg;
$badge = is_string($argsArr[1] ?? null) ? $argsArr[1] : '';
$this->alertUser($user, sprintf('Badge %s removed.', $badge));
break;
default:
+1
View File
@@ -23,6 +23,7 @@ parameters:
- '#Unsafe usage of new static#'
- '#uses generic trait .*HasFactory but does not specify its types#'
- '#extends generic class .*Factory but does not specify its types#'
- '#extends generic class .*Builder but does not specify its types#'
- '#return type with generic class .*Builder does not specify its types#'
- '#missingType\\.iterableValue#'
- '#should return array<string, mixed> but returns array#'
+8
View File
@@ -85,3 +85,11 @@
[2026-01-20 16:27:22] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd
[2026-01-20 16:27:49] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd
[2026-01-20 16:29:29] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd
[2026-01-20 16:36:38] production.ERROR: Allowed memory size of 536870912 bytes exhausted (tried to allocate 8388616 bytes) {"exception":"[object] (Symfony\\Component\\ErrorHandler\\Error\\FatalError(code: 0): Allowed memory size of 536870912 bytes exhausted (tried to allocate 8388616 bytes) at C:/Github/Epicnabbo-Catalogus-2025FullPack-Updated-Daily/Updated_Cms/vendor/iamcal/sql-parser/src/SQLParser.php:190)
[stacktrace]
#0 {main}
"}
[2026-01-20 16:36:40] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd
[2026-01-20 16:37:44] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd
[2026-01-20 16:37:44] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd
[2026-01-20 16:46:43] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd