ResetEnrollments::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace App\Console\Commands;
4
5
use App\Judite\Models\Shift;
6
use App\Judite\Models\Exchange;
7
use Illuminate\Console\Command;
8
use App\Judite\Models\Enrollment;
9
use Illuminate\Support\Facades\DB;
10
use App\Judite\Contracts\Registry\ExchangeRegistry;
11
12
class ResetEnrollments extends Command
13
{
14
    /**
15
     * The name and signature of the console command.
16
     *
17
     * @var string
18
     */
19
    protected $signature = 'reset:enrollments';
20
21
    /**
22
     * The console command description.
23
     *
24
     * @var string
25
     */
26
    protected $description = 'Delete existing enrollments and all data associated to them.';
27
28
    /**
29
     * Create a new command instance.
30
     */
31
    public function __construct()
32
    {
33
        parent::__construct();
34
    }
35
36
    /**
37
     * Execute the console command.
38
     *
39
     * @return mixed
40
     */
41
    public function handle()
42
    {
43
        DB::transaction(function () {
44
            // Delete exchange registry.
45
            resolve(ExchangeRegistry::class)->truncate();
46
47
            // Delete exchanges.
48
            Exchange::query()->delete();
49
50
            // Delete enrollments
51
            Enrollment::query()->delete();
52
53
            // Delete all shifts.
54
            Shift::query()->delete();
55
        });
56
    }
57
}
58