71 lines
1.8 KiB
PHP
71 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Exports;
|
|
|
|
use Illuminate\Support\Collection;
|
|
use Maatwebsite\Excel\Concerns\Exportable;
|
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
|
use Maatwebsite\Excel\Concerns\WithTitle;
|
|
|
|
class ProfileContactsExport implements FromCollection, WithTitle, WithHeadings, WithMapping
|
|
{
|
|
use Exportable;
|
|
|
|
protected $data;
|
|
|
|
public function __construct(Collection $data)
|
|
{
|
|
$this->data = $data;
|
|
}
|
|
|
|
public function collection()
|
|
{
|
|
return $this->data;
|
|
}
|
|
|
|
public function headings(): array
|
|
{
|
|
return [
|
|
__('Name'),
|
|
__('Full name'),
|
|
__('Profile type'),
|
|
__('Location'),
|
|
__('Has star'),
|
|
__('Has bookmark'),
|
|
__('Has transaction'),
|
|
__('Has conversation'),
|
|
__('Star count'),
|
|
__('Bookmark count'),
|
|
__('Transaction count'),
|
|
__('Message count'),
|
|
__('Last interaction'),
|
|
];
|
|
}
|
|
|
|
public function map($contact): array
|
|
{
|
|
return [
|
|
$contact['name'] ?? '',
|
|
$contact['full_name'] ?? '',
|
|
$contact['profile_type_name'] ?? '',
|
|
$contact['location'] ?? '',
|
|
$contact['has_star'] ? __('Yes') : __('No'),
|
|
$contact['has_bookmark'] ? __('Yes') : __('No'),
|
|
$contact['has_transaction'] ? __('Yes') : __('No'),
|
|
$contact['has_conversation'] ? __('Yes') : __('No'),
|
|
$contact['star_count'] ?? 0,
|
|
$contact['bookmark_count'] ?? 0,
|
|
$contact['transaction_count'] ?? 0,
|
|
$contact['message_count'] ?? 0,
|
|
$contact['last_interaction'] ?? '',
|
|
];
|
|
}
|
|
|
|
public function title(): string
|
|
{
|
|
return __('Contacts');
|
|
}
|
|
}
|