Skip to content

Instantly share code, notes, and snippets.

@ssx
Created December 27, 2018 13:40
Show Gist options
  • Save ssx/59ece214623f6eccec04f016920b481d to your computer and use it in GitHub Desktop.
Save ssx/59ece214623f6eccec04f016920b481d to your computer and use it in GitHub Desktop.
<?php
namespace App\Nova\Actions;
use App\Models\Order;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\LaravelNovaExcel\Actions\DownloadExcel;
use PhpOffice\PhpSpreadsheet\Shared\Date;
class ExportOrders extends DownloadExcel implements WithMapping, WithHeadings
{
/**
* @return array
*/
public function headings(): array
{
return [
'internal_order_id',
'created_at',
'stripe_transaction_id',
'buyer_name',
'buyer_email',
'billing_address',
'delivery_name',
'delivery_address',
'giftcard_amount',
'total_paid',
'message',
'status'
];
}
/**
* @param Order $order
*
* @return array
*/
public function map($order): array
{
return [
$order->id,
$order->created_at,
$order->transaction_id,
$order->buyer_name,
$order->buyer_email,
$order->billing_address,
$order->recipient_name,
$order->delivery_address,
$order->amount,
$order->total,
$order->notes,
$order->status
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment