🆙 Refactor Cleanup started 🆙

This commit is contained in:
Remco
2026-01-20 18:58:15 +01:00
parent d57e97bb42
commit a71a634dee
8 changed files with 86 additions and 73 deletions
@@ -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);
return collect($files)->map(fn ($file) => [
'filename' => basename($file),
'path' => $file,
])->toArray();
$result = [];
foreach ($files as $file) {
$path = is_string($file) ? $file : '';
$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\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Form;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\Page; // Import the Notification class
use Filament\Resources\Pages\Page;
class ManageBadgeUploads extends Page implements HasForms
{
use InteractsWithForms;
public $badge_file;
public ?string $badge_file = null;
protected static string $resource = \App\Filament\Resources\Hotel\BadgeUploads\BadgeUploadResource::class;
protected string $view = 'filament.pages.manage-badge-uploads';
public function mount(): void
{
$this->form->fill([]);
}
public function mount(): void {}
protected function getFormSchema(): array
public function form(Form $form): Form
{
return [
return $form->schema([
FileUpload::make('badge_file')
->label('Upload Badge')
->disk('badges')
@@ -33,13 +31,11 @@ class ManageBadgeUploads extends Page implements HasForms
->acceptedFileTypes(['image/gif'])
->rules(['mimes:gif'])
->required(),
];
]);
}
public function save(): void
{
$this->form->getState();
Notification::make()
->title('Badge uploaded successfully!')
->success()