Completed
Push — develop ( 046539...192a32 )
by Francisco
05:06
created

ResendConfirmationEmail::handle()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 1
nop 0
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace App\Console\Commands;
4
5
use App\Judite\Models\Student;
6
use Illuminate\Console\Command;
7
use Illuminate\Support\Facades\DB;
8
use Illuminate\Support\Facades\Mail;
9
use App\Mail\RegistrationConfirmation;
10
11
class ResendConfirmationEmail extends Command
12
{
13
    /**
14
     * The name and signature of the console command.
15
     *
16
     * @var string
17
     */
18
    protected $signature = 'emails:confirmation';
19
20
    /**
21
     * The console command description.
22
     *
23
     * @var string
24
     */
25
    protected $description = 'Resend confirmation e-mail';
26
27
    /**
28
     * Create a new command instance.
29
     */
30
    public function __construct()
31
    {
32
        parent::__construct();
33
    }
34
35
    /**
36
     * Execute the console command.
37
     *
38
     * @return mixed
39
     */
40
    public function handle()
41
    {
42
        DB::transaction(function () {
43
            $students = Student::with('user')->get();
44
            $students->each(function ($student) {
45
                $user = $student->user;
46
                if ($user->verified) {
47
                    return;
48
                }
49
50
                Mail::to($user)->send(new RegistrationConfirmation($user));
51
            });
52
        });
53
    }
54
}
55