Deploy 2: 2FA (App + Email) + REST API + CSV import-export + auto backup
- Filament v5 multiFactorAuthentication enabled on both panels (App + Email) - HasAppAuthentication + HasEmailAuthentication on User and SuperAdmin - Migration: app_authentication_secret + recovery_codes + email_authentication_at - Sanctum REST API: /api/v1/login, /me, clients, vehicles, work-orders - EnsureTokenMatchesTenant middleware blocks cross-tenant token usage - CsvImportExport service: clients + vehicles bulk via plain CSV - Import/Export buttons on Client + Vehicle list pages - ApiTokens page in tenant panel (generate/revoke + last-used) - BackupAllTenantsCommand + scheduler (daily 03:00, retain 14 days) - Background scheduler in entrypoint.sh
This commit is contained in:
@@ -3,7 +3,10 @@
|
||||
namespace App\Filament\Tenant\Resources\ClientResource\Pages;
|
||||
|
||||
use App\Filament\Tenant\Resources\ClientResource;
|
||||
use App\Services\CsvImportExport;
|
||||
use Filament\Actions;
|
||||
use Filament\Forms;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListClients extends ListRecords
|
||||
@@ -12,6 +15,37 @@ class ListClients extends ListRecords
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [Actions\CreateAction::make()];
|
||||
return [
|
||||
Actions\Action::make('export')
|
||||
->label('Export CSV')
|
||||
->icon('heroicon-m-arrow-down-tray')
|
||||
->color('gray')
|
||||
->action(fn () => app(CsvImportExport::class)->exportClients()),
|
||||
Actions\Action::make('import')
|
||||
->label('Import CSV')
|
||||
->icon('heroicon-m-arrow-up-tray')
|
||||
->color('gray')
|
||||
->modalHeading('Import clienți din CSV')
|
||||
->modalDescription('CSV cu header: ' . implode(', ', CsvImportExport::CLIENT_COLUMNS) . '. Deduplicare după telefon.')
|
||||
->schema([
|
||||
Forms\Components\FileUpload::make('file')
|
||||
->required()
|
||||
->disk('local')
|
||||
->directory('imports')
|
||||
->acceptedFileTypes(['text/csv', 'text/plain', 'application/csv'])
|
||||
->maxSize(5120),
|
||||
])
|
||||
->action(function (array $data) {
|
||||
$abs = \Illuminate\Support\Facades\Storage::disk('local')->path($data['file']);
|
||||
$r = app(CsvImportExport::class)->importClients($abs);
|
||||
@unlink($abs);
|
||||
Notification::make()
|
||||
->title("Import: {$r['imported']} adăugați, {$r['skipped']} ignorați")
|
||||
->body(empty($r['errors']) ? null : implode("\n", array_slice($r['errors'], 0, 8)))
|
||||
->{empty($r['errors']) ? 'success' : 'warning'}()
|
||||
->send();
|
||||
}),
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,10 @@
|
||||
namespace App\Filament\Tenant\Resources\VehicleResource\Pages;
|
||||
|
||||
use App\Filament\Tenant\Resources\VehicleResource;
|
||||
use App\Services\CsvImportExport;
|
||||
use Filament\Actions;
|
||||
use Filament\Forms;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListVehicles extends ListRecords
|
||||
@@ -12,6 +15,37 @@ class ListVehicles extends ListRecords
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [Actions\CreateAction::make()];
|
||||
return [
|
||||
Actions\Action::make('export')
|
||||
->label('Export CSV')
|
||||
->icon('heroicon-m-arrow-down-tray')
|
||||
->color('gray')
|
||||
->action(fn () => app(CsvImportExport::class)->exportVehicles()),
|
||||
Actions\Action::make('import')
|
||||
->label('Import CSV')
|
||||
->icon('heroicon-m-arrow-up-tray')
|
||||
->color('gray')
|
||||
->modalHeading('Import mașini din CSV')
|
||||
->modalDescription('CSV cu header: ' . implode(', ', CsvImportExport::VEHICLE_COLUMNS) . '. Coloana client_phone trebuie să existe deja la clienți.')
|
||||
->schema([
|
||||
Forms\Components\FileUpload::make('file')
|
||||
->required()
|
||||
->disk('local')
|
||||
->directory('imports')
|
||||
->acceptedFileTypes(['text/csv', 'text/plain', 'application/csv'])
|
||||
->maxSize(5120),
|
||||
])
|
||||
->action(function (array $data) {
|
||||
$abs = \Illuminate\Support\Facades\Storage::disk('local')->path($data['file']);
|
||||
$r = app(CsvImportExport::class)->importVehicles($abs);
|
||||
@unlink($abs);
|
||||
Notification::make()
|
||||
->title("Import: {$r['imported']} adăugate, {$r['skipped']} ignorate")
|
||||
->body(empty($r['errors']) ? null : implode("\n", array_slice($r['errors'], 0, 8)))
|
||||
->{empty($r['errors']) ? 'success' : 'warning'}()
|
||||
->send();
|
||||
}),
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user