-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
adf39e0
commit 30f0334
Showing
6 changed files
with
188 additions
and
23 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
app/Filament/Resources/VolunteerResource/Actions/ExportVolunteersExample.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Filament\Resources\VolunteerResource\Actions; | ||
|
||
use App\Models\Volunteer; | ||
use pxlrbt\FilamentExcel\Actions\Pages\ExportAction; | ||
use pxlrbt\FilamentExcel\Columns\Column; | ||
use pxlrbt\FilamentExcel\Exports\ExcelExport; | ||
|
||
class ExportVolunteersExample extends ExportAction | ||
{ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
$this->label(__('volunteer.labels.download_example')); | ||
|
||
$this->exports([ | ||
ExcelExport::make() | ||
->withColumns([ | ||
Column::make('first_name'), | ||
Column::make('last_name'), | ||
Column::make('email'), | ||
Column::make('phone'), | ||
Column::make('cnp'), | ||
Column::make('rol'), | ||
Column::make('specialisations'), | ||
Column::make('has_first_aid_accreditation'), | ||
Column::make('county') | ||
->formatStateUsing(fn ($state) => $state->name), | ||
Column::make('city') | ||
->formatStateUsing(fn ($state) => $state->name), | ||
]), | ||
]); | ||
} | ||
|
||
public function handleExport(array $data) | ||
{ | ||
$examples = Volunteer::factory() | ||
->count(10) | ||
->make() | ||
->each(function ($item) { | ||
$item->load('county'); | ||
$item->load('city'); | ||
|
||
return $item; | ||
}); | ||
|
||
$examplesArray = []; | ||
foreach ($examples as $example) { | ||
$examplesArray[] = $example; | ||
} | ||
|
||
$exportable = $this->getSelectedExport($data); | ||
$livewire = $this->getLivewire(); | ||
|
||
return app()->call([$exportable, 'hydrate'], [ | ||
'livewire' => $this->getLivewire(), | ||
'records' => $examples, | ||
'formData' => data_get($data, $exportable->getName()), | ||
])->export(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
return [ | ||
'import' => 'Import', | ||
'skip_header' => 'Omite prima linie', | ||
'match_to_column' => 'Mapeaza coloanele', | ||
// 'import_failed' => 'Import failed, please check your import file and try again', | ||
// 'import_failed_title' => 'Import Failed', | ||
// 'import_succeeded' => 'Import of :count row(s) succeeded, :skipped skipped row(s)', | ||
// 'import_succeeded_title' => 'Import Succeeded', | ||
]; |