mirror of
https://github.com/anna-sara/vbytes_lan.git
synced 2026-03-16 16:25:41 +01:00
Exporter for volunteers
This commit is contained in:
parent
8c8b51cb33
commit
896340b7e2
2 changed files with 43 additions and 0 deletions
38
app/Filament/Exports/VolunteerExporter.php
Normal file
38
app/Filament/Exports/VolunteerExporter.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\Volunteer;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
use Illuminate\Support\Number;
|
||||
|
||||
class VolunteerExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = Volunteer::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ExportColumn::make('lan_id'),
|
||||
ExportColumn::make('first_name'),
|
||||
ExportColumn::make('surname'),
|
||||
ExportColumn::make('phone'),
|
||||
ExportColumn::make('email'),
|
||||
ExportColumn::make('gdpr'),
|
||||
ExportColumn::make('areas'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your volunteer export has completed and ' . Number::format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' ' . Number::format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
|
|
@ -16,6 +16,7 @@ use Filament\Support\Icons\Heroicon;
|
|||
use Filament\Tables\Columns\TextInputColumn;
|
||||
use App\Models\Volunteer;
|
||||
use App\Models\Mailtemplate;
|
||||
use App\Filament\Exports\VolunteerExporter;
|
||||
|
||||
class VolunteersTable
|
||||
{
|
||||
|
|
@ -23,6 +24,10 @@ class VolunteersTable
|
|||
{
|
||||
return $table
|
||||
->recordAction(null)
|
||||
->headerActions([
|
||||
ExportAction::make()
|
||||
->exporter(VolunteerExporter::class),
|
||||
])
|
||||
->columns([
|
||||
TextInputColumn::make('lan_id')
|
||||
->label('ID')
|
||||
|
|
|
|||
Loading…
Reference in a new issue