private function export() { $output = fopen('php://output', 'w') or Utils::fatalError(); header('Content-Type:application/csv'); header('Content-Disposition:attachment;filename=export.csv'); $clients = Client::scope()->get(); Utils::exportData($output, $clients->toArray()); $contacts = Contact::scope()->get(); Utils::exportData($output, $contacts->toArray()); $invoices = Invoice::scope()->get(); Utils::exportData($output, $invoices->toArray()); $invoiceItems = InvoiceItem::scope()->get(); Utils::exportData($output, $invoiceItems->toArray()); $payments = Payment::scope()->get(); Utils::exportData($output, $payments->toArray()); $credits = Credit::scope()->get(); Utils::exportData($output, $credits->toArray()); fclose($output); exit; }