Skip to content

Commit

Permalink
fixed #389
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed Jun 21, 2018
1 parent da5035e commit 89158e8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
20 changes: 15 additions & 5 deletions app/Http/Controllers/Expenses/Bills.php
Expand Up @@ -539,11 +539,21 @@ public function export()
$tables = ['items', 'histories', 'payments', 'totals'];
foreach ($tables as $table) {
$excel->sheet('bill_' . $table, function($sheet) use ($bills, $table) {
$bills->each(function ($bill) use ($sheet, $table) {
$sheet->fromModel($bill->$table->makeHidden([
'id', 'company_id', 'created_at', 'updated_at', 'deleted_at'
]));
});
$hidden_fields = ['id', 'company_id', 'created_at', 'updated_at', 'deleted_at'];

$i = 1;
foreach ($bills as $bill) {
$model = $bill->$table->makeHidden($hidden_fields);

if ($i == 1) {
$sheet->fromModel($model, null, 'A1', false);
} else {
// Don't put multiple heading columns
$sheet->fromModel($model, null, 'A1', false, false);
}

$i++;
}
});
}
})->download('xlsx');
Expand Down
20 changes: 15 additions & 5 deletions app/Http/Controllers/Incomes/Invoices.php
Expand Up @@ -560,11 +560,21 @@ public function export()
$tables = ['items', 'histories', 'payments', 'totals'];
foreach ($tables as $table) {
$excel->sheet('invoice_' . $table, function($sheet) use ($invoices, $table) {
$invoices->each(function ($bill) use ($sheet, $table) {
$sheet->fromModel($bill->$table->makeHidden([
'id', 'company_id', 'created_at', 'updated_at', 'deleted_at'
]));
});
$hidden_fields = ['id', 'company_id', 'created_at', 'updated_at', 'deleted_at'];

$i = 1;
foreach ($invoices as $invoice) {
$model = $invoice->$table->makeHidden($hidden_fields);

if ($i == 1) {
$sheet->fromModel($model, null, 'A1', false);
} else {
// Don't put multiple heading columns
$sheet->fromModel($model, null, 'A1', false, false);
}

$i++;
}
});
}
})->download('xlsx');
Expand Down

0 comments on commit 89158e8

Please sign in to comment.