2019-11-16 10:21:14 +03:00
|
|
|
<?php
|
|
|
|
|
2019-12-31 15:49:09 +03:00
|
|
|
namespace App\Exports\Purchases\Sheets;
|
2019-11-16 10:21:14 +03:00
|
|
|
|
2020-01-20 02:05:40 +03:00
|
|
|
use App\Abstracts\Export;
|
2019-12-31 15:49:09 +03:00
|
|
|
use App\Models\Purchase\BillHistory as Model;
|
2019-11-16 10:21:14 +03:00
|
|
|
|
2020-01-20 02:05:40 +03:00
|
|
|
class BillHistories extends Export
|
2019-11-16 10:21:14 +03:00
|
|
|
{
|
|
|
|
public function collection()
|
|
|
|
{
|
2020-06-07 12:11:37 +03:00
|
|
|
$model = Model::with('bill')->usingSearchString(request('search'));
|
2019-11-16 10:21:14 +03:00
|
|
|
|
2020-01-20 02:05:40 +03:00
|
|
|
if (!empty($this->ids)) {
|
|
|
|
$model->whereIn('bill_id', (array) $this->ids);
|
2019-11-16 10:21:14 +03:00
|
|
|
}
|
|
|
|
|
2020-03-02 23:13:36 +03:00
|
|
|
return $model->cursor();
|
2019-11-16 10:21:14 +03:00
|
|
|
}
|
|
|
|
|
2020-01-21 09:55:12 +03:00
|
|
|
public function map($model): array
|
|
|
|
{
|
2020-02-21 21:37:48 +03:00
|
|
|
$bill = $model->bill;
|
|
|
|
|
|
|
|
if (empty($bill)) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
$model->bill_number = $bill->bill_number;
|
2020-01-21 09:55:12 +03:00
|
|
|
|
|
|
|
return parent::map($model);
|
|
|
|
}
|
|
|
|
|
2020-01-20 02:05:40 +03:00
|
|
|
public function fields(): array
|
2019-11-16 10:21:14 +03:00
|
|
|
{
|
|
|
|
return [
|
2020-01-21 09:55:12 +03:00
|
|
|
'bill_number',
|
2020-01-11 16:57:32 +03:00
|
|
|
'status',
|
2019-11-16 10:21:14 +03:00
|
|
|
'notify',
|
|
|
|
'description',
|
|
|
|
];
|
|
|
|
}
|
2020-01-11 16:57:32 +03:00
|
|
|
}
|