Import|Export

This commit is contained in:
David Bomba 2020-12-14 16:03:23 +11:00
parent d115609d3c
commit c0aa30ab58

View File

@ -11,7 +11,28 @@
namespace App\Export\CSV namespace App\Export\CSV
use App\Models\Company;
class InvoiceExport class InvoiceExport
{ {
private $company;
public function __construct(Company $company)
{
$this->company = $company;
}
public function export()
{
$fileName = 'test.csv';
$data = $this->company->invoices->get();
return Excel::create($fileName, function ($excel) use ($data) {
$excel->sheet('', function ($sheet) use ($data) {
$sheet->loadView('export', $data);
});
})->download('csv');
}
} }