55 lines
2.0 KiB
PHP
55 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Exports;
|
|
|
|
use Maatwebsite\Excel\Concerns\FromArray;
|
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
use Carbon\Carbon;
|
|
|
|
class DashboardExportUser implements FromArray, WithHeadings
|
|
{
|
|
protected $data;
|
|
|
|
public function __construct(array $data)
|
|
{
|
|
$this->data = $data;
|
|
}
|
|
|
|
public function array(): array
|
|
{
|
|
return array_map(function ($transaction) {
|
|
return [
|
|
'ID' => $transaction['id'],
|
|
'Customer Name' => $transaction['iam_principal']['first_name'] . ' ' . $transaction['iam_principal']['last_name'],
|
|
'Customer ID' => $transaction['iam_principal']['id'],
|
|
'Amount' => '$' . number_format($transaction['amount'], 2),
|
|
'Product Name' => $transaction['subscription_product']['product_name'],
|
|
'Product Details' => $transaction['subscription_product']['product_details'],
|
|
'Subscription Status' => $transaction['subscription_status'],
|
|
'Subscription Period Start' => Carbon::parse($transaction['current_period_start'])->format('m/d/Y h:i A'),
|
|
'Subscription Period End' => Carbon::parse($transaction['current_period_end'])->format('m/d/Y h:i A'),
|
|
'Next Payment Date' => Carbon::parse($transaction['next_payment_date'])->format('m/d/Y h:i A'),
|
|
// 'Subscription Period Start' => $transaction['current_period_start'],
|
|
// 'Subscription Period End' => $transaction['current_period_end'],
|
|
// 'Next Payment Date' => $transaction['next_payment_date'],
|
|
];
|
|
}, $this->data);
|
|
}
|
|
|
|
public function headings(): array
|
|
{
|
|
return [
|
|
'ID',
|
|
'Customer Name',
|
|
'Customer ID',
|
|
'Amount',
|
|
'Product Name',
|
|
'Product Details',
|
|
'Subscription Status',
|
|
'Subscription Period Start',
|
|
'Subscription Period End',
|
|
'Next Payment Date'
|
|
];
|
|
}
|
|
}
|