export abstract
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Exports\Purchases\Sheets;
|
||||
|
||||
use App\Abstracts\Export;
|
||||
use App\Models\Purchase\BillItem as Model;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
@@ -9,40 +10,20 @@ use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithTitle;
|
||||
|
||||
class BillItems implements FromCollection, ShouldAutoSize, WithHeadings, WithMapping, WithTitle
|
||||
class BillItems extends Export
|
||||
{
|
||||
public $bill_ids;
|
||||
|
||||
public function __construct($bill_ids = null)
|
||||
{
|
||||
$this->bill_ids = $bill_ids;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->bill_ids)) {
|
||||
$model->whereIn('bill_id', (array) $this->bill_ids);
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('bill_id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->get();
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
{
|
||||
return [
|
||||
$model->bill_id,
|
||||
$model->item_id,
|
||||
$model->name,
|
||||
$model->quantity,
|
||||
$model->price,
|
||||
$model->total,
|
||||
$model->tax,
|
||||
];
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
public function fields(): array
|
||||
{
|
||||
return [
|
||||
'bill_id',
|
||||
@@ -54,9 +35,4 @@ class BillItems implements FromCollection, ShouldAutoSize, WithHeadings, WithMap
|
||||
'tax',
|
||||
];
|
||||
}
|
||||
|
||||
public function title(): string
|
||||
{
|
||||
return 'bill_items';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user