payments import/export

This commit is contained in:
denisdulici
2020-01-21 00:04:10 +03:00
parent 04173eae78
commit 9b42e2d127
3 changed files with 44 additions and 5 deletions

View File

@@ -9,7 +9,7 @@ class Payments extends Export
{
public function collection()
{
$model = Model::type('expense')->usingSearchString(request('search'));
$model = Model::with(['account', 'bill', 'category', 'contact'])->type('expense')->usingSearchString(request('search'));
if (!empty($this->ids)) {
$model->whereIn('id', (array) $this->ids);
@@ -18,6 +18,16 @@ class Payments extends Export
return $model->get();
}
public function map($model): array
{
$model->account_name = $model->account->name;
$model->bill_number = $model->bill ? $model->bill->bill_number : 0;
$model->contact_email = $model->contact->email;
$model->category_name = $model->category->name;
return parent::map($model);
}
public function fields(): array
{
return [
@@ -25,10 +35,10 @@ class Payments extends Export
'amount',
'currency_code',
'currency_rate',
'account_id',
'document_id',
'contact_id',
'category_id',
'account_name',
'bill_number',
'contact_email',
'category_name',
'description',
'payment_method',
'reference',