You've already forked Epicnabbo-Catalogus-Updated-Daily
🆙 Refactor Cleanup started 🆙
This commit is contained in:
+36
-22
@@ -77,6 +77,9 @@ class WebsiteDrawBadgeResource extends Resource
|
|||||||
->limit(35)
|
->limit(35)
|
||||||
->tooltip(function (TextColumn $column): ?string {
|
->tooltip(function (TextColumn $column): ?string {
|
||||||
$state = $column->getState();
|
$state = $column->getState();
|
||||||
|
if (! is_string($state)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (strlen($state) <= $column->getCharacterLimit()) {
|
if (strlen($state) <= $column->getCharacterLimit()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -91,7 +94,7 @@ class WebsiteDrawBadgeResource extends Resource
|
|||||||
->getStateUsing(function (WebsiteDrawBadgeModel $record): string {
|
->getStateUsing(function (WebsiteDrawBadgeModel $record): string {
|
||||||
$appUrl = config('app.url');
|
$appUrl = config('app.url');
|
||||||
$appUrl = is_string($appUrl) ? $appUrl : '';
|
$appUrl = is_string($appUrl) ? $appUrl : '';
|
||||||
$badgeUrl = is_string($record->badge_url) ? $record->badge_url : '';
|
$badgeUrl = (string) $record->badge_url;
|
||||||
return $appUrl . $badgeUrl;
|
return $appUrl . $badgeUrl;
|
||||||
})
|
})
|
||||||
->extraAttributes(['style' => 'image-rendering: pixelated'])
|
->extraAttributes(['style' => 'image-rendering: pixelated'])
|
||||||
@@ -102,7 +105,8 @@ class WebsiteDrawBadgeResource extends Resource
|
|||||||
->recordActions([
|
->recordActions([
|
||||||
DeleteAction::make()
|
DeleteAction::make()
|
||||||
->before(function (DeleteAction $action, WebsiteDrawBadge $record): void {
|
->before(function (DeleteAction $action, WebsiteDrawBadge $record): void {
|
||||||
$badgeCode = pathinfo($record->badge_path, PATHINFO_FILENAME);
|
$badgePath = (string) $record->badge_path;
|
||||||
|
$badgeCode = pathinfo($badgePath, PATHINFO_FILENAME);
|
||||||
|
|
||||||
// Remove the badge from any user before deleting it.
|
// Remove the badge from any user before deleting it.
|
||||||
if ($record->published) {
|
if ($record->published) {
|
||||||
@@ -113,27 +117,34 @@ class WebsiteDrawBadgeResource extends Resource
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove from JSON
|
// Remove from JSON
|
||||||
$filePath = DB::table('website_settings')->where('key', 'nitro_external_texts_file')->value('value');
|
$filePathValue = DB::table('website_settings')->where('key', 'nitro_external_texts_file')->value('value');
|
||||||
|
$filePath = is_string($filePathValue) ? $filePathValue : '';
|
||||||
|
|
||||||
if ($filePath && file_exists($filePath) && is_writable($filePath)) {
|
if ($filePath !== '' && file_exists($filePath) && is_writable($filePath)) {
|
||||||
$json = json_decode(file_get_contents($filePath), true);
|
$jsonRaw = @file_get_contents($filePath);
|
||||||
unset($json["badge_name_{$badgeCode}"]);
|
$json = is_string($jsonRaw) ? json_decode($jsonRaw, true) : [];
|
||||||
unset($json["badge_desc_{$badgeCode}"]);
|
$data = is_array($json) ? $json : [];
|
||||||
file_put_contents($filePath, json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
unset($data["badge_name_{$badgeCode}"]);
|
||||||
|
unset($data["badge_desc_{$badgeCode}"]);
|
||||||
|
file_put_contents($filePath, json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete the badge file from the filesystem
|
// Delete the badge file from the filesystem
|
||||||
$badgePath = $record->badge_path;
|
$badgePathFs = (string) $record->badge_path;
|
||||||
if ($badgePath && file_exists($badgePath)) {
|
if ($badgePathFs !== '' && file_exists($badgePathFs)) {
|
||||||
unlink($badgePath);
|
unlink($badgePathFs);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
->toolbarActions([
|
->toolbarActions([
|
||||||
DeleteBulkAction::make()
|
DeleteBulkAction::make()
|
||||||
->before(function (DeleteBulkAction $action, $records): void {
|
->before(function (DeleteBulkAction $action, iterable $records): void {
|
||||||
foreach ($records as $record) {
|
foreach ($records as $record) {
|
||||||
$badgeCode = pathinfo((string) $record->badge_path, PATHINFO_FILENAME);
|
if (! ($record instanceof WebsiteDrawBadgeModel)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$badgePath = (string) $record->badge_path;
|
||||||
|
$badgeCode = pathinfo($badgePath, PATHINFO_FILENAME);
|
||||||
|
|
||||||
// Remove the badge from any user before deleting it.
|
// Remove the badge from any user before deleting it.
|
||||||
if ($record->published) {
|
if ($record->published) {
|
||||||
@@ -143,18 +154,21 @@ class WebsiteDrawBadgeResource extends Resource
|
|||||||
->delete();
|
->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
$filePath = DB::table('website_settings')->where('key', 'nitro_external_texts_file')->value('value');
|
$filePathValue = DB::table('website_settings')->where('key', 'nitro_external_texts_file')->value('value');
|
||||||
|
$filePath = is_string($filePathValue) ? $filePathValue : '';
|
||||||
|
|
||||||
if ($filePath && file_exists($filePath) && is_writable($filePath)) {
|
if ($filePath !== '' && file_exists($filePath) && is_writable($filePath)) {
|
||||||
$json = json_decode(file_get_contents($filePath), true);
|
$jsonRaw = @file_get_contents($filePath);
|
||||||
unset($json["badge_name_{$badgeCode}"]);
|
$json = is_string($jsonRaw) ? json_decode($jsonRaw, true) : [];
|
||||||
unset($json["badge_desc_{$badgeCode}"]);
|
$data = is_array($json) ? $json : [];
|
||||||
file_put_contents($filePath, json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
unset($data["badge_name_{$badgeCode}"]);
|
||||||
|
unset($data["badge_desc_{$badgeCode}"]);
|
||||||
|
file_put_contents($filePath, json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
||||||
}
|
}
|
||||||
|
|
||||||
$badgePath = $record->badge_path;
|
$badgePathFs = (string) $record->badge_path;
|
||||||
if ($badgePath && file_exists($badgePath)) {
|
if ($badgePathFs !== '' && file_exists($badgePathFs)) {
|
||||||
unlink($badgePath);
|
unlink($badgePathFs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class AchievementResource extends Resource
|
|||||||
Select::make('category')
|
Select::make('category')
|
||||||
->native(false)
|
->native(false)
|
||||||
->label(__('filament::resources.inputs.category'))
|
->label(__('filament::resources.inputs.category'))
|
||||||
->options(AchievementCategory::toInput()),
|
->options(fn () => AchievementCategory::toInput()),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
Tab::make(__('filament::resources.tabs.Configurations'))
|
Tab::make(__('filament::resources.tabs.Configurations'))
|
||||||
@@ -74,7 +74,7 @@ class AchievementResource extends Resource
|
|||||||
Select::make('visible')
|
Select::make('visible')
|
||||||
->native(false)
|
->native(false)
|
||||||
->label(__('filament::resources.inputs.visible'))
|
->label(__('filament::resources.inputs.visible'))
|
||||||
->options([
|
->options(fn () => [
|
||||||
'1' => __('filament::resources.common.Yes'),
|
'1' => __('filament::resources.common.Yes'),
|
||||||
'0' => __('filament::resources.common.No'),
|
'0' => __('filament::resources.common.No'),
|
||||||
]),
|
]),
|
||||||
@@ -82,7 +82,7 @@ class AchievementResource extends Resource
|
|||||||
Select::make('reward_type')
|
Select::make('reward_type')
|
||||||
->native(false)
|
->native(false)
|
||||||
->label(__('filament::resources.inputs.reward_type'))
|
->label(__('filament::resources.inputs.reward_type'))
|
||||||
->options(CurrencyTypes::toInput()),
|
->options(fn () => CurrencyTypes::toInput()),
|
||||||
|
|
||||||
TextInput::make('reward_amount')
|
TextInput::make('reward_amount')
|
||||||
->label(__('filament::resources.inputs.reward_amount'))
|
->label(__('filament::resources.inputs.reward_amount'))
|
||||||
@@ -137,7 +137,7 @@ class AchievementResource extends Resource
|
|||||||
])
|
])
|
||||||
->filters([
|
->filters([
|
||||||
SelectFilter::make('visible')
|
SelectFilter::make('visible')
|
||||||
->options([
|
->options(fn () => [
|
||||||
'1' => __('filament::resources.common.Yes'),
|
'1' => __('filament::resources.common.Yes'),
|
||||||
'0' => __('filament::resources.common.No'),
|
'0' => __('filament::resources.common.No'),
|
||||||
])
|
])
|
||||||
@@ -145,7 +145,7 @@ class AchievementResource extends Resource
|
|||||||
->placeholder(__('filament::resources.common.All')),
|
->placeholder(__('filament::resources.common.All')),
|
||||||
|
|
||||||
SelectFilter::make('category')
|
SelectFilter::make('category')
|
||||||
->options(AchievementCategory::toInput())
|
->options(fn () => AchievementCategory::toInput())
|
||||||
->label(__('filament::resources.columns.category'))
|
->label(__('filament::resources.columns.category'))
|
||||||
->placeholder(__('filament::resources.common.All')),
|
->placeholder(__('filament::resources.common.All')),
|
||||||
])
|
])
|
||||||
|
|||||||
+4
-10
@@ -63,8 +63,7 @@ class BadgeTextEditorResource extends Resource
|
|||||||
ImageColumn::make('badge_key')
|
ImageColumn::make('badge_key')
|
||||||
->label('Badge Image')
|
->label('Badge Image')
|
||||||
->getStateUsing(function (WebsiteBadge $record) use ($badgesPath): string {
|
->getStateUsing(function (WebsiteBadge $record) use ($badgesPath): string {
|
||||||
$badgeKey = is_string($record->badge_key) ? $record->badge_key : '';
|
$badgeName = str_replace('badge_desc_', '', (string) $record->badge_key);
|
||||||
$badgeName = str_replace('badge_desc_', '', $badgeKey);
|
|
||||||
|
|
||||||
return asset($badgesPath . $badgeName . '.gif');
|
return asset($badgesPath . $badgeName . '.gif');
|
||||||
})
|
})
|
||||||
@@ -73,21 +72,16 @@ class BadgeTextEditorResource extends Resource
|
|||||||
TextColumn::make('badge_name')
|
TextColumn::make('badge_name')
|
||||||
->label('Badge Code & Name')
|
->label('Badge Code & Name')
|
||||||
->formatStateUsing(function (WebsiteBadge $record): string {
|
->formatStateUsing(function (WebsiteBadge $record): string {
|
||||||
$key = is_string($record->badge_key) ? $record->badge_key : '';
|
return (string) $record->badge_key . ' : ' . (string) $record->badge_name;
|
||||||
$name = is_string($record->badge_name) ? $record->badge_name : '';
|
|
||||||
return $key . ' : ' . $name;
|
|
||||||
})
|
})
|
||||||
->searchable(query: function ($query, $search): void {
|
->searchable(query: function (\Illuminate\Database\Eloquent\Builder $query, string $search): void {
|
||||||
$query->where('badge_key', 'like', "%{$search}%")
|
$query->where('badge_key', 'like', "%{$search}%")
|
||||||
->orWhere('badge_name', 'like', "%{$search}%");
|
->orWhere('badge_name', 'like', "%{$search}%");
|
||||||
})
|
})
|
||||||
->sortable(),
|
->sortable(),
|
||||||
TextColumn::make('badge_description')
|
TextColumn::make('badge_description')
|
||||||
->label('Badge Description')
|
->label('Badge Description')
|
||||||
->getStateUsing(function (WebsiteBadge $record): string {
|
->getStateUsing(fn (WebsiteBadge $record): string => Str::limit((string) $record->badge_description, 65))
|
||||||
$desc = is_string($record->badge_description) ? $record->badge_description : '';
|
|
||||||
return Str::limit($desc, 65);
|
|
||||||
})
|
|
||||||
->searchable(),
|
->searchable(),
|
||||||
])
|
])
|
||||||
->filters([])
|
->filters([])
|
||||||
|
|||||||
+10
-8
@@ -41,10 +41,9 @@ class ListBadgeTextEditors extends ListRecords
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function exportToJson(SettingsService $settingsService)
|
public function exportToJson(SettingsService $settingsService): void
|
||||||
{
|
{
|
||||||
$jsonPath = $settingsService->getOrDefault('nitro_external_texts_file');
|
$jsonPath = $settingsService->getOrDefault('nitro_external_texts_file');
|
||||||
|
|
||||||
if ($jsonPath === '' || $jsonPath === '0') {
|
if ($jsonPath === '' || $jsonPath === '0') {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Export Failed')
|
->title('Export Failed')
|
||||||
@@ -65,16 +64,19 @@ class ListBadgeTextEditors extends ListRecords
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$jsonData = json_decode(file_get_contents($jsonPath), true);
|
$raw = @file_get_contents($jsonPath);
|
||||||
|
$jsonData = is_string($raw) ? json_decode($raw, true) : [];
|
||||||
|
$jsonData = is_array($jsonData) ? $jsonData : [];
|
||||||
|
|
||||||
$badges = WebsiteBadge::all();
|
$badges = WebsiteBadge::all();
|
||||||
$badgeKeys = $badges->pluck('badge_key')->toArray();
|
$badgeKeys = $badges->pluck('badge_key')->toArray();
|
||||||
|
|
||||||
foreach ($jsonData as $key => $value) {
|
foreach ($jsonData as $key => $value) {
|
||||||
if (
|
if (! is_string($key)) {
|
||||||
(str_starts_with((string) $key, 'badge_desc_') || str_starts_with((string) $key, 'badge_name_')) &&
|
continue;
|
||||||
! in_array(str_replace(['badge_desc_', 'badge_name_'], '', $key), $badgeKeys)
|
}
|
||||||
) {
|
$isBadgeKey = str_starts_with($key, 'badge_desc_') || str_starts_with($key, 'badge_name_');
|
||||||
|
if ($isBadgeKey && ! in_array(str_replace(['badge_desc_', 'badge_name_'], '', $key), $badgeKeys, true)) {
|
||||||
unset($jsonData[$key]);
|
unset($jsonData[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,7 +112,7 @@ class ListBadgeTextEditors extends ListRecords
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createBackup(SettingsService $settingsService)
|
public function createBackup(SettingsService $settingsService): void
|
||||||
{
|
{
|
||||||
$jsonPath = $settingsService->getOrDefault('nitro_external_texts_file');
|
$jsonPath = $settingsService->getOrDefault('nitro_external_texts_file');
|
||||||
|
|
||||||
|
|||||||
@@ -56,14 +56,20 @@ class BadgeUploadResource extends Resource
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getFiles(): array
|
public static function getFiles(): mixed
|
||||||
{
|
{
|
||||||
$badgePath = env('BadgePath', 'badges');
|
$settings = app(\App\Services\SettingsService::class);
|
||||||
|
$badgePath = $settings->getOrDefault('badge_path_filesystem', 'badges') ?: 'badges';
|
||||||
$files = Storage::disk('local')->files($badgePath);
|
$files = Storage::disk('local')->files($badgePath);
|
||||||
|
|
||||||
return collect($files)->map(fn ($file) => [
|
$result = [];
|
||||||
'filename' => basename($file),
|
foreach ($files as $file) {
|
||||||
'path' => $file,
|
$path = is_string($file) ? $file : '';
|
||||||
])->toArray();
|
$result[] = [
|
||||||
|
'filename' => $path !== '' ? basename($path) : '',
|
||||||
|
'path' => $path,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,27 +5,25 @@ namespace App\Filament\Resources\Hotel\BadgeUploads\Pages;
|
|||||||
use Filament\Forms\Components\FileUpload;
|
use Filament\Forms\Components\FileUpload;
|
||||||
use Filament\Forms\Concerns\InteractsWithForms;
|
use Filament\Forms\Concerns\InteractsWithForms;
|
||||||
use Filament\Forms\Contracts\HasForms;
|
use Filament\Forms\Contracts\HasForms;
|
||||||
|
use Filament\Forms\Form;
|
||||||
use Filament\Notifications\Notification;
|
use Filament\Notifications\Notification;
|
||||||
use Filament\Resources\Pages\Page; // Import the Notification class
|
use Filament\Resources\Pages\Page;
|
||||||
|
|
||||||
class ManageBadgeUploads extends Page implements HasForms
|
class ManageBadgeUploads extends Page implements HasForms
|
||||||
{
|
{
|
||||||
use InteractsWithForms;
|
use InteractsWithForms;
|
||||||
|
|
||||||
public $badge_file;
|
public ?string $badge_file = null;
|
||||||
|
|
||||||
protected static string $resource = \App\Filament\Resources\Hotel\BadgeUploads\BadgeUploadResource::class;
|
protected static string $resource = \App\Filament\Resources\Hotel\BadgeUploads\BadgeUploadResource::class;
|
||||||
|
|
||||||
protected string $view = 'filament.pages.manage-badge-uploads';
|
protected string $view = 'filament.pages.manage-badge-uploads';
|
||||||
|
|
||||||
public function mount(): void
|
public function mount(): void {}
|
||||||
{
|
|
||||||
$this->form->fill([]);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getFormSchema(): array
|
public function form(Form $form): Form
|
||||||
{
|
{
|
||||||
return [
|
return $form->schema([
|
||||||
FileUpload::make('badge_file')
|
FileUpload::make('badge_file')
|
||||||
->label('Upload Badge')
|
->label('Upload Badge')
|
||||||
->disk('badges')
|
->disk('badges')
|
||||||
@@ -33,13 +31,11 @@ class ManageBadgeUploads extends Page implements HasForms
|
|||||||
->acceptedFileTypes(['image/gif'])
|
->acceptedFileTypes(['image/gif'])
|
||||||
->rules(['mimes:gif'])
|
->rules(['mimes:gif'])
|
||||||
->required(),
|
->required(),
|
||||||
];
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function save(): void
|
public function save(): void
|
||||||
{
|
{
|
||||||
$this->form->getState();
|
|
||||||
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Badge uploaded successfully!')
|
->title('Badge uploaded successfully!')
|
||||||
->success()
|
->success()
|
||||||
|
|||||||
+9
-11
@@ -451,20 +451,18 @@ class CatalogItemsRelationManager extends RelationManager
|
|||||||
])
|
])
|
||||||
->action(function (array $data, CatalogItem $record): void {
|
->action(function (array $data, CatalogItem $record): void {
|
||||||
// Transform any null or empty values to empty strings
|
// Transform any null or empty values to empty strings
|
||||||
$data = collect($data)->map(function ($value) {
|
$normalized = [];
|
||||||
if ($value === null || $value === '') {
|
foreach ($data as $key => $value) {
|
||||||
return '';
|
$normalized[(string) $key] = match (true) {
|
||||||
}
|
$value === null, $value === '' => '',
|
||||||
if (is_bool($value)) {
|
is_bool($value) => $value ? '1' : '0',
|
||||||
return $value ? '1' : '0';
|
default => $value,
|
||||||
}
|
};
|
||||||
|
}
|
||||||
return $value;
|
|
||||||
})->toArray();
|
|
||||||
|
|
||||||
$itemBase = $record->itemBase;
|
$itemBase = $record->itemBase;
|
||||||
if ($itemBase) {
|
if ($itemBase) {
|
||||||
$itemBase->forceFill($data)->save();
|
$itemBase->forceFill($normalized)->save();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
->visible(function (CatalogItem $record): bool {
|
->visible(function (CatalogItem $record): bool {
|
||||||
|
|||||||
@@ -99,3 +99,6 @@
|
|||||||
"}
|
"}
|
||||||
[2026-01-20 17:19:05] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd
|
[2026-01-20 17:19:05] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd
|
||||||
[2026-01-20 17:19:06] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd
|
[2026-01-20 17:19:06] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd
|
||||||
|
[2026-01-20 17:32:06] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd
|
||||||
|
[2026-01-20 17:55:31] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd
|
||||||
|
[2026-01-20 17:55:31] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd
|
||||||
|
|||||||
Reference in New Issue
Block a user