webseite funktioniert, pay sdk, blog backend funktioniert

This commit is contained in:
Codex Agent
2025-09-29 22:16:12 +02:00
parent e52a4005aa
commit 21c9391e2c
51 changed files with 2093 additions and 1293 deletions

View File

@@ -93,6 +93,135 @@ class PackageResource extends Resource
]);
}
public static function featuresToRepeaterItems(mixed $features): array
{
if (is_string($features)) {
$decoded = json_decode($features, true);
if (is_string($decoded)) {
$decoded = json_decode($decoded, true);
}
$features = json_last_error() === JSON_ERROR_NONE ? $decoded : null;
}
if ($features === null) {
return [];
}
if (! is_array($features)) {
return [];
}
if (! array_is_list($features)) {
return collect($features)
->map(function ($value, $key) {
return [
'key' => (string) $key,
'value' => is_bool($value) ? ($value ? 'true' : 'false') : (string) $value,
];
})
->values()
->all();
}
return collect($features)
->map(function ($item) {
if (is_array($item)) {
return [
'key' => (string) ($item['key'] ?? ''),
'value' => (string) ($item['value'] ?? ''),
];
}
return [
'key' => (string) $item,
'value' => 'true',
];
})
->values()
->all();
}
public static function featuresFromRepeaterItems(mixed $items): array
{
if (! is_array($items)) {
return [];
}
$features = [];
foreach ($items as $item) {
if (! is_array($item)) {
continue;
}
$key = isset($item['key']) ? trim((string) $item['key']) : '';
if ($key === '') {
continue;
}
$value = $item['value'] ?? true;
if (is_string($value)) {
$normalized = strtolower(trim($value));
if (in_array($normalized, ['1', 'true', 'yes', 'on'], true)) {
$value = true;
} elseif (in_array($normalized, ['0', 'false', 'no', 'off'], true)) {
$value = false;
}
}
if (is_array($value)) {
$value = $value['value'] ?? $value['enabled'] ?? true;
}
$features[$key] = (bool) $value;
}
return $features;
}
public static function formatFeaturesForDisplay(mixed $features): string
{
$map = $features;
if (! is_array($map)) {
if (is_string($map)) {
$decoded = json_decode($map, true);
if (is_string($decoded)) {
$decoded = json_decode($decoded, true);
}
$map = json_last_error() === JSON_ERROR_NONE ? $decoded : [];
} else {
$map = [];
}
}
if (! array_is_list($map)) {
return collect($map)
->filter(fn ($value) => (bool) $value)
->keys()
->implode(', ');
}
return collect($map)
->map(function ($item) {
if (is_array($item)) {
return (string) ($item['key'] ?? '');
}
return (string) $item;
})
->filter()
->implode(', ');
}
public static function table(Table $table): Table
{
return $table
@@ -119,6 +248,7 @@ class PackageResource extends Resource
->color('primary'),
TextColumn::make('features')
->label('Features')
->formatStateUsing(fn ($state) => static::formatFeaturesForDisplay($state))
->limit(50),
])
->filters([
@@ -150,4 +280,4 @@ class PackageResource extends Resource
'edit' => Pages\EditPackage::route('/{record}/edit'),
];
}
}
}