예제 #1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     /** @var \Maatwebsite\Excel\Excel $excel */
     $excel = app('excel');
     $excel->create('issues', function ($excel) {
         $excel->sheet('issues', function ($sheet) {
             $issues = Issue::latest()->get();
             $headers = ['Title', 'Description', 'Resolution'];
             $row = 1;
             $sheet->row($row, $headers);
             foreach ($issues as $issue) {
                 $row++;
                 $resolution = $issue->findCommentResolution();
                 $sheet->row($row, [$issue->title, $issue->description, $resolution ? $resolution->content : null]);
             }
         });
     })->store('xls');
 }