Skip to content

Commit

Permalink
event application excel export added.
Browse files Browse the repository at this point in the history
  • Loading branch information
karabayyazilim committed Jul 7, 2024
1 parent 2056e03 commit f6b34a3
Show file tree
Hide file tree
Showing 4 changed files with 597 additions and 4 deletions.
71 changes: 71 additions & 0 deletions app/Exports/EventApplicationExport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

namespace App\Exports;

use App\Models\EventApplication;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;

class EventApplicationExport implements FromCollection, WithMapping, WithHeadings
{
/**
* @return \Illuminate\Support\Collection
*/
public function collection(): \Illuminate\Support\Collection
{
return EventApplication::with(['city', 'user'])->get();
}

public function headings(): array
{
return [
'Başvuru ID',
'Adı Soyadı',
'E-Posta',
'Telefon',
'Şehir',
'İş',
'Çadır',
'Uyku Tulumu',
'Mat',
'Sandalye',
'Teleskop',
'Teleskop Markası',
'Dürbün',
'Kamera',
'Tripod',
'Telsiz',
'Bilgisayar',
'Geliş Tarihi',
'Ayrılış Tarihi',
'Check-In Tarihi',
];
}

public function map($eventApplication): array
{
return [
$eventApplication->id,
$eventApplication->user->name,
$eventApplication->user->email,
$eventApplication->user->phone,
$eventApplication->city->name,
$eventApplication->job,
$eventApplication->tent,
$eventApplication->sleeping_bag,
$eventApplication->mat,
$eventApplication->chair,
$eventApplication->telescope,
$eventApplication->telescope_brand,
$eventApplication->binocular,
$eventApplication->camera,
$eventApplication->tripod,
$eventApplication->walkie_talkie,
$eventApplication->computer,
$eventApplication->arrival_date,
$eventApplication->departure_date,
$eventApplication->check_in,
];
}
}
11 changes: 8 additions & 3 deletions app/Filament/Resources/EventApplicationResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Filament\Resources;

use App\Exports\EventApplicationExport;
use App\Filament\Resources\EventApplicationResource\Pages;
use App\Filament\Resources\EventApplicationResource\RelationManagers;
use App\Models\Event;
Expand All @@ -15,7 +16,7 @@
use FontLib\TrueType\Collection;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Maatwebsite\Excel\Facades\Excel;

class EventApplicationResource extends Resource
{
Expand Down Expand Up @@ -116,10 +117,14 @@ public static function table(Table $table): Table
{
return $table
->headerActions([
Tables\Actions\Action::make('download')
->label('Excel Olarak İndir')
->color('gray')
->action(fn(): \Symfony\Component\HttpFoundation\BinaryFileResponse => Excel::download(new EventApplicationExport(), 'etkinlik-başvurulari.xlsx')),
Tables\Actions\Action::make('create')
->label('Başvuru Oluştur')
->url(fn (): string => route('application.index', Event::first()->id))
->openUrlInNewTab()
->url(fn(): string => route('application.index', Event::first()->id))
->openUrlInNewTab(),
])
->columns([
Tables\Columns\TextColumn::make('id')
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"inertiajs/inertia-laravel": "^1.2",
"laravel/framework": "^11.9",
"laravel/tinker": "^2.9",
"maatwebsite/excel": "^3.1",
"predis/predis": "^2.2",
"simplesoftwareio/simple-qrcode": "^4.2"
},
Expand Down
Loading

0 comments on commit f6b34a3

Please sign in to comment.