validate(); if (!RateLimiter::attempt('import:'.auth()->user()->id, $perMinute = 3, fn()=>null)) { $this->error(__('Hang on! You\'re doing that too much.')); return; } $this->backupImport = BackupImportModel::create([ 'user_id' => auth()->user()->id, 'path' => $this->file->getPathname() ]); $this->importStatusDialog = true; } public function checkImportStatus() { if (Str::contains($this->backupImport?->message, 'portfolios')) { $this->percent = (1/2) * 100; } if (Str::contains($this->backupImport?->message, 'transactions')) { $this->percent = (3/4) * 100; } if (Str::contains($this->backupImport?->message, 'daily changes')) { $this->percent = (7/8) * 100; } if ($this->backupImport?->status == 'failed') { unset($this->file); $this->percent = 100; } if ($this->backupImport?->status == 'success') { $this->importStatusDialog = false; $this->backupImport = null; $this->success(__('Successfully imported!'), redirectTo: route('dashboard')); } } public function downloadTemplate() { return Excel::download(new BackupExport(empty: true), now()->format('Y_m_d') . '_investbrain_template.xlsx'); } }; ?> {{ __('Import') }} {{ __('Upload or recover your Investbrain portfolio and holdings.') }} {{ __('Download import template.') }}
@if($backupImport?->status)
{{ $backupImport?->message }}
@endif
@if($backupImport?->status != 'failed') @endif @if($backupImport?->status == 'failed') {{ __('Try again') }} @else
{{ __('Your import will continue in the background') }}
{{ __('Close') }} @endif
{{ __('Saved.') }} {{ __('Import') }}