Initial commit
This commit is contained in:
70
app/Exports/ProfileContactsExport.php
Normal file
70
app/Exports/ProfileContactsExport.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user