23-01-2026
This commit is contained in:
parent
8fd1f4d451
commit
389d5d1820
59 changed files with 9642 additions and 883 deletions
76
app/Exports/NewsletterExport.php
Normal file
76
app/Exports/NewsletterExport.php
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\NewsletterContact;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
|
||||
class NewsletterExport implements FromCollection, WithHeadings, WithMapping, ShouldAutoSize
|
||||
{
|
||||
protected $contacts;
|
||||
|
||||
public function __construct($contacts)
|
||||
{
|
||||
$this->contacts = $contacts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
return $this->contacts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'ID',
|
||||
'E-Mail',
|
||||
'Vorname',
|
||||
'Nachname',
|
||||
'Gruppe Kulturreisen',
|
||||
'Gruppe Ferienwohnungen',
|
||||
'Status',
|
||||
'Herkunft',
|
||||
'Buchungen Kulturreisen',
|
||||
'Buchungen Ferienwohnungen',
|
||||
'Letzte Buchung',
|
||||
'Letzte Reise',
|
||||
'Angemeldet am',
|
||||
'Abgemeldet am',
|
||||
'Erstellt am',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param NewsletterContact $contact
|
||||
* @return array
|
||||
*/
|
||||
public function map($contact): array
|
||||
{
|
||||
return [
|
||||
$contact->id,
|
||||
$contact->email,
|
||||
$contact->firstname,
|
||||
$contact->lastname,
|
||||
$contact->group_kulturreisen ? 'Ja' : 'Nein',
|
||||
$contact->group_ferienwohnungen ? 'Ja' : 'Nein',
|
||||
$contact->status_label,
|
||||
$contact->source_label,
|
||||
$contact->total_bookings_kulturreisen,
|
||||
$contact->total_bookings_ferienwohnungen,
|
||||
$contact->last_booking_at ? $contact->last_booking_at->format('d.m.Y') : '',
|
||||
$contact->last_travel_end_date ? $contact->last_travel_end_date->format('d.m.Y') : '',
|
||||
$contact->subscribed_at ? $contact->subscribed_at->format('d.m.Y H:i') : '',
|
||||
$contact->unsubscribed_at ? $contact->unsubscribed_at->format('d.m.Y H:i') : '',
|
||||
$contact->created_at->format('d.m.Y H:i'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue