f7fc69077b
- Convert static $modelLabel/$pluralModelLabel/$title to getter methods - Wrap ->label()/->placeholder()/->helperText()/->description()/->title()/->body() args - Wrap Section::make()/Fieldset::make()/Notification::make()->title() args - Fix RelationManagers::getTitle() signature to match parent (Model, string) - Fix Pages::getTitle() to instance method (BasePage::getTitle is non-static) - Extend lang/ru.json + lang/en.json with 700+ common terms; identity fallback for the rest - Remove duplicate getters in 5 resources that had manual getModelLabel already All 306 tests pass. Missing translations fall back to the RO key so the UI never breaks. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
52 lines
2.1 KiB
PHP
52 lines
2.1 KiB
PHP
<?php
|
|
|
|
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
|
|
{
|
|
protected static string $resource = ClientResource::class;
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
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(),
|
|
];
|
|
}
|
|
}
|