label('Import'); $this->authorize(fn () => auth()->user()->can('import egg')); $this->form([ Tabs::make('Tabs') ->contained(false) ->tabs([ Tab::make('From File') ->icon('tabler-file-upload') ->schema([ FileUpload::make('egg') ->label('Egg') ->hint('This should be the json file ( egg-minecraft.json )') ->acceptedFileTypes(['application/json']) ->storeFiles(false) ->multiple(), ]), Tab::make('From URL') ->icon('tabler-world-upload') ->schema([ TextInput::make('url') ->label('URL') ->hint('This URL should point to a single json file') ->url(), ]), ]), ]); $this->action(function (array $data, EggImporterService $eggImportService): void { try { if (!empty($data['egg'])) { $eggFile = $data['egg']; foreach ($eggFile as $file) { $eggImportService->fromFile($file); } } if (!empty($data['url'])) { $eggImportService->fromUrl($data['url']); } } catch (Exception $exception) { Notification::make() ->title('Import Failed') ->body($exception->getMessage()) ->danger() ->send(); report($exception); return; } Notification::make() ->title('Import Success') ->success() ->send(); }); } }