🆙 More fixes 🆙

This commit is contained in:
Remco
2026-01-19 23:22:33 +01:00
parent 7f253b5261
commit 35202aa825
10 changed files with 49 additions and 26 deletions
@@ -2,38 +2,46 @@
namespace App\Filament\Traits; namespace App\Filament\Traits;
use Str; use Illuminate\Support\Str;
trait TranslatableResource trait TranslatableResource
{ {
public static function getNavigationGroup(): ?string public static function getNavigationGroup(): ?string
{ {
$group = property_exists(static::class, 'navigationGroup') ? static::$navigationGroup : null;
$groupStr = is_string($group) ? $group : ($group instanceof \UnitEnum ? $group->name : '');
return __( return __(
sprintf('filament::resources.navigations.%s', static::$navigationGroup), sprintf('filament::resources.navigations.%s', $groupStr),
); );
} }
public static function getPluralModelLabel(): string public static function getPluralModelLabel(): string
{ {
$identifier = property_exists(static::class, 'translateIdentifier') ? static::$translateIdentifier : '';
$identifierStr = is_string($identifier) ? $identifier : ($identifier instanceof \UnitEnum ? $identifier->name : '');
return __(sprintf( return __(sprintf(
Str::endsWith(static::class, 'RelationManager') Str::endsWith(static::class, 'RelationManager')
? 'filament::resources.resources.%s.navigation_label' ? 'filament::resources.resources.%s.navigation_label'
: 'filament::resources.resources.%s.plural', : 'filament::resources.resources.%s.plural',
static::$translateIdentifier, $identifierStr,
)); ));
} }
public static function getNavigationLabel(): string public static function getNavigationLabel(): string
{ {
$identifier = property_exists(static::class, 'translateIdentifier') ? static::$translateIdentifier : '';
$identifierStr = is_string($identifier) ? $identifier : ($identifier instanceof \UnitEnum ? $identifier->name : '');
return __( return __(
sprintf('filament::resources.resources.%s.navigation_label', static::$translateIdentifier), sprintf('filament::resources.resources.%s.navigation_label', $identifierStr),
); );
} }
public static function getModelLabel(): string public static function getModelLabel(): string
{ {
$identifier = property_exists(static::class, 'translateIdentifier') ? static::$translateIdentifier : '';
$identifierStr = is_string($identifier) ? $identifier : ($identifier instanceof \UnitEnum ? $identifier->name : '');
return __( return __(
sprintf('filament::resources.resources.%s.label', static::$translateIdentifier), sprintf('filament::resources.resources.%s.label', $identifierStr),
); );
} }
} }
@@ -45,10 +45,10 @@ class ArticlesAggregateChart extends ChartWidget
'datasets' => [ 'datasets' => [
[ [
'label' => $label, 'label' => $label,
'data' => $data->map(fn (TrendValue $value) => $value->aggregate), 'data' => $data->map(fn ($value) => data_get($value, 'aggregate')),
], ],
], ],
'labels' => $data->map(fn (TrendValue $value) => $value->date), 'labels' => $data->map(fn ($value) => data_get($value, 'date')),
]; ];
} }
@@ -20,31 +20,31 @@ class TopDashboardOverview extends BaseWidget
protected function getStats(): array protected function getStats(): array
{ {
return [ return [
Stat::make(__('filament::resources.stats.users_count.title'), Number::format(User::count(), '0', '1', app()->getLocale())) Stat::make(__('filament::resources.stats.users_count.title'), Number::format(User::count(), 0, 1, app()->getLocale()))
->description(__('filament::resources.stats.users_count.description')) ->description(__('filament::resources.stats.users_count.description'))
->chart([20, 20]) ->chart([20, 20])
->descriptionIcon('heroicon-m-user-group', IconPosition::Before) ->descriptionIcon('heroicon-m-user-group', IconPosition::Before)
->color('success'), ->color('success'),
Stat::make(__('filament::resources.stats.furniture_count.title'), Number::format(ItemDefinition::count(), '0', '1', app()->getLocale())) Stat::make(__('filament::resources.stats.furniture_count.title'), Number::format(ItemDefinition::count(), 0, 1, app()->getLocale()))
->description(__('filament::resources.stats.furniture_count.description')) ->description(__('filament::resources.stats.furniture_count.description'))
->descriptionIcon('heroicon-m-cube', IconPosition::Before) ->descriptionIcon('heroicon-m-cube', IconPosition::Before)
->chart([20, 20]) ->chart([20, 20])
->color('success'), ->color('success'),
Stat::make(__('filament::resources.stats.rooms_count.title'), Number::format(Room::count(), '0', '1', app()->getLocale())) Stat::make(__('filament::resources.stats.rooms_count.title'), Number::format(Room::count(), 0, 1, app()->getLocale()))
->description(__('filament::resources.stats.rooms_count.description')) ->description(__('filament::resources.stats.rooms_count.description'))
->descriptionIcon('heroicon-m-building-storefront', IconPosition::Before) ->descriptionIcon('heroicon-m-building-storefront', IconPosition::Before)
->chart([20, 20]) ->chart([20, 20])
->color('success'), ->color('success'),
Stat::make(__('filament::resources.stats.photos_count.title'), Number::format(CameraWeb::count(), '0', '1', app()->getLocale())) Stat::make(__('filament::resources.stats.photos_count.title'), Number::format(CameraWeb::count(), 0, 1, app()->getLocale()))
->description(__('filament::resources.stats.photos_count.description')) ->description(__('filament::resources.stats.photos_count.description'))
->descriptionIcon('heroicon-m-camera', IconPosition::Before) ->descriptionIcon('heroicon-m-camera', IconPosition::Before)
->chart([20, 20]) ->chart([20, 20])
->color('success'), ->color('success'),
Stat::make(__('filament::resources.stats.badge_count.title'), Number::format(WebsiteBadge::count(), '0', '1', app()->getLocale())) Stat::make(__('filament::resources.stats.badge_count.title'), Number::format(WebsiteBadge::count(), 0, 1, app()->getLocale()))
->description(__('filament::resources.stats.badge_count.description')) ->description(__('filament::resources.stats.badge_count.description'))
->descriptionIcon('heroicon-m-gif', IconPosition::Before) ->descriptionIcon('heroicon-m-gif', IconPosition::Before)
->chart([20, 20]) ->chart([20, 20])
+10 -9
View File
@@ -35,16 +35,14 @@ if (! function_exists('isDarkColor')) {
if (! function_exists('hasPermission')) { if (! function_exists('hasPermission')) {
function hasPermission(string $permission): bool function hasPermission(string $permission): bool
{ {
$value = app(PermissionsService::class)->getOrDefault($permission); return app(PermissionsService::class)->getOrDefault($permission);
return $value === true || $value === 1 || $value === '1';
} }
} }
if (! function_exists('hasHousekeepingPermission')) { if (! function_exists('hasHousekeepingPermission')) {
function hasHousekeepingPermission(string $permission): bool function hasHousekeepingPermission(string $permission): bool
{ {
$value = app(HousekeepingPermissionsService::class)->getOrDefault($permission); return app(HousekeepingPermissionsService::class)->getOrDefault($permission);
return $value === true || $value === 1 || $value === '1';
} }
} }
@@ -59,9 +57,11 @@ if (! function_exists('findMigration')) {
function findMigration(string $tableName): string function findMigration(string $tableName): string
{ {
static $cache = []; static $cache = [];
$cache = is_array($cache) ? $cache : [];
if (isset($cache[$tableName])) { if (isset($cache[$tableName])) {
return $cache[$tableName]; $cached = $cache[$tableName];
return is_string($cached) ? $cached : '';
} }
$migrationsPath = database_path('migrations'); $migrationsPath = database_path('migrations');
@@ -75,8 +75,9 @@ if (! function_exists('findMigration')) {
if ($file->isFile() && $file->getExtension() === 'php') { if ($file->isFile() && $file->getExtension() === 'php') {
$content = @file_get_contents($file->getPathname()); $content = @file_get_contents($file->getPathname());
if ($content !== false && str_contains($content, "Schema::create('$tableName'")) { if ($content !== false && str_contains($content, "Schema::create('$tableName'")) {
$cache[$tableName] = $file->getFilename(); $filename = (string) $file->getFilename();
return $file->getFilename(); $cache[$tableName] = $filename;
return $filename;
} }
} }
} }
@@ -110,8 +111,8 @@ if (! function_exists('dropForeignKeyIfExists')) {
->pluck('CONSTRAINT_NAME'); ->pluck('CONSTRAINT_NAME');
foreach ($foreignKeys as $foreignKey) { foreach ($foreignKeys as $foreignKey) {
if (! empty($foreignKey)) { if (is_string($foreignKey) && $foreignKey !== '') {
$connection->statement("ALTER TABLE {$table} DROP FOREIGN KEY {$foreignKey}"); $connection->statement('ALTER TABLE ' . $table . ' DROP FOREIGN KEY ' . $foreignKey);
} }
} }
} }
+5 -1
View File
@@ -72,7 +72,6 @@ use App\Models\ChatlogPrivate;
*/ */
class User extends Authenticatable implements FilamentUser, HasName class User extends Authenticatable implements FilamentUser, HasName
{ {
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasApiTokens, HasFactory, LogsActivity, Notifiable, TwoFactorAuthenticatable; use HasApiTokens, HasFactory, LogsActivity, Notifiable, TwoFactorAuthenticatable;
public $timestamps = false; public $timestamps = false;
@@ -311,6 +310,11 @@ class User extends Authenticatable implements FilamentUser, HasName
return $this->hasMany(CameraWeb::class); return $this->hasMany(CameraWeb::class);
} }
protected static function newFactory(): \Database\Factories\UserFactory
{
return \Database\Factories\UserFactory::new();
}
/** /**
* @return HasMany<WebsiteUserGuestbook, $this> * @return HasMany<WebsiteUserGuestbook, $this>
*/ */
+1 -1
View File
@@ -105,6 +105,6 @@ return [
| |
*/ */
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_cache_'), 'prefix' => env('CACHE_PREFIX', Str::slug((string) env('APP_NAME', 'laravel'), '_') . '_cache_'),
]; ];
+1 -1
View File
@@ -142,7 +142,7 @@ return [
'options' => [ 'options' => [
'cluster' => env('REDIS_CLUSTER', 'redis'), 'cluster' => env('REDIS_CLUSTER', 'redis'),
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_database_'), 'prefix' => env('REDIS_PREFIX', Str::slug((string) env('APP_NAME', 'laravel'), '_') . '_database_'),
], ],
'default' => [ 'default' => [
+1 -1
View File
@@ -128,7 +128,7 @@ return [
'cookie' => env( 'cookie' => env(
'SESSION_COOKIE', 'SESSION_COOKIE',
Str::slug(env('APP_NAME', 'laravel'), '_') . '_session', Str::slug((string) env('APP_NAME', 'laravel'), '_') . '_session',
), ),
/* /*
@@ -2,11 +2,15 @@
namespace Database\Factories; namespace Database\Factories;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
class UserFactory extends Factory class UserFactory extends Factory<User>
{ {
/** @var class-string<User> */
protected $model = User::class;
public function definition(): array public function definition(): array
{ {
return [ return [
+6
View File
@@ -61,3 +61,9 @@
[2026-01-19 21:12:03] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd [2026-01-19 21:12:03] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd
[2026-01-19 21:30:09] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd [2026-01-19 21:30:09] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd
[2026-01-19 21:30:09] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd [2026-01-19 21:30:09] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd
[2026-01-19 21:37:29] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd
[2026-01-19 21:37:29] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd
[2026-01-19 22:12:15] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd
[2026-01-19 22:12:15] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd
[2026-01-19 22:18:51] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd
[2026-01-19 22:18:53] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd