Example #1
0
 /**
  * Export listing to CSV format.
  * @return Response
  */
 public function export()
 {
     $domains = Domain::all();
     $columns = ['contact' => 'Contact', 'domain' => 'Domain name', 'enabled' => 'Status'];
     $output = '"' . implode('","', $columns) . '"' . PHP_EOL;
     foreach ($domains as $domain) {
         $row = [$domain->contact->name . ' (' . $domain->contact->reference . ')', $domain['name'], $domain['enabled'] ? 'Enabled' : 'Disabled'];
         $output .= '"' . implode('","', $row) . '"' . PHP_EOL;
     }
     return response(substr($output, 0, -1), 200)->header('Content-Type', 'text/csv')->header('Content-Disposition', 'attachment; filename="Domains.csv"');
 }
Example #2
0
 /**
  * Export listing to CSV format.
  *
  * @param  string $format
  * @return \Illuminate\Http\Response
  */
 public function export($format)
 {
     $domains = Domain::all();
     if ($format === 'csv') {
         $columns = ['contact' => 'Contact', 'domain' => 'Domain name', 'enabled' => 'Status'];
         $output = '"' . implode('","', $columns) . '"' . PHP_EOL;
         foreach ($domains as $domain) {
             $row = [$domain->contact->name . ' (' . $domain->contact->reference . ')', $domain['name'], $domain['enabled'] ? 'Enabled' : 'Disabled'];
             $output .= '"' . implode('","', $row) . '"' . PHP_EOL;
         }
         return response(substr($output, 0, -1), 200)->header('Content-Type', 'text/csv')->header('Content-Disposition', 'attachment; filename="Domains.csv"');
     }
     return Redirect::route('admin.domains.index')->with('message', "The requested format {$format} is not available for exports");
 }
Example #3
0
 /**
  * {@inheritdoc}.
  */
 protected function findAll()
 {
     return Domain::all();
 }