2019-11-16 10:21:14 +03:00
|
|
|
<?php
|
|
|
|
|
2019-12-31 15:49:09 +03:00
|
|
|
namespace App\Exports\Sales\Sheets;
|
2019-11-16 10:21:14 +03:00
|
|
|
|
2019-12-31 15:49:09 +03:00
|
|
|
use App\Models\Sale\InvoiceHistory as Model;
|
2019-11-16 10:21:14 +03:00
|
|
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
|
|
|
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
|
|
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
|
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
|
|
|
use Maatwebsite\Excel\Concerns\WithTitle;
|
|
|
|
|
|
|
|
class InvoiceHistories implements FromCollection, ShouldAutoSize, WithHeadings, WithMapping, WithTitle
|
|
|
|
{
|
|
|
|
public $invoice_ids;
|
|
|
|
|
|
|
|
public function __construct($invoice_ids = null)
|
|
|
|
{
|
|
|
|
$this->invoice_ids = $invoice_ids;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function collection()
|
|
|
|
{
|
|
|
|
$model = Model::usingSearchString(request('search'));
|
|
|
|
|
|
|
|
if (!empty($this->invoice_ids)) {
|
|
|
|
$model->whereIn('invoice_id', (array) $this->invoice_ids);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $model->get();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function map($model): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
$model->invoice_id,
|
2020-01-11 16:57:32 +03:00
|
|
|
$model->status,
|
2019-11-16 10:21:14 +03:00
|
|
|
$model->notify,
|
|
|
|
$model->description,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function headings(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'invoice_id',
|
2020-01-11 16:57:32 +03:00
|
|
|
'status',
|
2019-11-16 10:21:14 +03:00
|
|
|
'notify',
|
|
|
|
'description',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function title(): string
|
|
|
|
{
|
|
|
|
return 'invoice_histories';
|
|
|
|
}
|
2020-01-11 16:57:32 +03:00
|
|
|
}
|