/**
  * Export listing to CSV format.
  *
  * @return Response
  */
 public function export()
 {
     $tickets = Ticket::all();
     $columns = ['id' => 'Ticket ID'];
     $output = '"' . implode('", "', $columns) . '"' . PHP_EOL;
     foreach ($tickets as $ticket) {
         $row = [$ticket->id];
         $output .= '"' . implode('", "', $row) . '"' . PHP_EOL;
     }
     return response(substr($output, 0, -1), 200)->header('Content-Type', 'text/csv')->header('Content-Disposition', 'attachment; filename="Tickets.csv"');
 }
示例#2
0
 /**
  * Export tickets to CSV format.
  *
  * @param string $format
  * @return \Illuminate\Http\Response
  */
 public function export($format)
 {
     // TODO #AIO-?? ExportProvider - (mark) Move this into an ExportProvider or something s?
     $tickets = Ticket::all();
     if ($format === 'csv') {
         $columns = ['id' => 'Ticket ID', 'ip' => 'IP address', 'class_id' => 'Classification', 'type_id' => 'Type', 'first_seen' => 'First seen', 'last_seen' => 'Last seen', 'event_count' => 'Events', 'status_id' => 'Ticket Status'];
         $output = '"' . implode('", "', $columns) . '"' . PHP_EOL;
         foreach ($tickets as $ticket) {
             $row = [$ticket->id, $ticket->ip, $ticket->class_id, $ticket->type_id, $ticket->firstEvent[0]->seen, $ticket->lastEvent[0]->seen, $ticket->events->count(), trans('types.status.' . $ticket->status_id . '.name')];
             $output .= '"' . implode('", "', $row) . '"' . PHP_EOL;
         }
         return response(substr($output, 0, -1), 200)->header('Content-Type', 'text/csv')->header('Content-Disposition', 'attachment; filename="Tickets.csv"');
     }
     return Redirect::route('admin.contacts.index')->with('message', "The requested format {$format} is not available for exports");
 }
示例#3
0
 /**
  * {@inheritdoc}.
  */
 protected function findAll()
 {
     return Ticket::all();
 }
 /**
  * Export tickets to CSV format.
  *
  * @param string $format
  *
  * @return \Illuminate\Http\Response
  */
 public function export($format)
 {
     // TODO #AIO-?? ExportProvider - (mark) Move this into an ExportProvider or something?
     // only export all tickets when we are in the systemaccount
     $auth_account = $this->auth_user->account;
     if ($auth_account->isSystemAccount()) {
         $tickets = Ticket::all();
     } else {
         $tickets = Ticket::select('tickets.*')->where('ip_contact_account_id', $auth_account->id)->orWhere('domain_contact_account_id', $auth_account);
     }
     if ($format === 'csv') {
         $columns = ['id' => 'Ticket ID', 'ip' => 'IP address', 'class_id' => 'Classification', 'type_id' => 'Type', 'first_seen' => 'First seen', 'last_seen' => 'Last seen', 'event_count' => 'Events', 'status_id' => 'Ticket Status'];
         $output = '"' . implode('", "', $columns) . '"' . PHP_EOL;
         foreach ($tickets as $ticket) {
             $row = [$ticket->id, $ticket->ip, trans("classifications.{$ticket->class_id}.name"), trans("types.type.{$ticket->type_id}.name"), $ticket->firstEvent[0]->seen, $ticket->lastEvent[0]->seen, $ticket->events->count(), trans("types.status.abusedesk.{$ticket->status_id}.name")];
             $output .= '"' . implode('", "', $row) . '"' . PHP_EOL;
         }
         return response(substr($output, 0, -1), 200)->header('Content-Type', 'text/csv')->header('Content-Disposition', 'attachment; filename="Tickets.csv"');
     }
     return Redirect::route('admin.contacts.index')->with('message', "The requested format {$format} is not available for exports");
 }