CompletedTrainingExportHandler   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
c 0
b 0
f 0
lcom 0
cbo 1
dl 0
loc 16
ccs 0
cts 8
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 13 1
1
<?php
2
3
namespace SET\Handlers\Excel;
4
5
use Maatwebsite\Excel\Files\ExportHandler;
6
use SET\Training;
7
use SET\User;
8
9
class CompletedTrainingExportHandler implements ExportHandler
10
{
11
    public function handle($export)
12
    {
13
        return $export->sheet('User-Training', function ($sheet) {
14
            $trainings = Training::all();
15
            $users = User::skipSystem()->with([
16
                'assignedTrainings' => function ($q) {
17
                    $q->whereNotNull('completed_date')->orderBy('completed_date', 'desc');
18
                },
19
            ])->active()->orderBy('last_name')->get();
20
21
            $sheet->loadView('report.completed_training', ['users' => $users, 'trainings' => $trainings]);
22
        })->download('xlsx');
23
    }
24
}
25