Passed
Push — master ( 26caeb...0e28f7 )
by Thomas
11:18
created

migrateLeadStatuses::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace App\Console\Commands;
4
5
use App\Models\Student;
6
use Illuminate\Console\Command;
7
8
class migrateLeadStatuses extends Command
9
{
10
    /**
11
     * The name and signature of the console command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'leadstatus:migrate';
16
17
    /**
18
     * The console command description.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Command description';
23
24
    /**
25
     * Create a new command instance.
26
     *
27
     * @return void
28
     */
29
    public function __construct()
30
    {
31
        parent::__construct();
32
    }
33
34
    /**
35
     * Execute the console command.
36
     *
37
     * @return int
38
     */
39
    public function handle()
40
    {
41
        foreach (Student::where('lead_type_id', 1)->get() as $student) {
42
            $student->update(['lead_type_id' => null]);
43
        }
44
45
        foreach (Student::enrolled()->get() as $student) {
46
            $student->update(['lead_type_id' => 1]);
47
        }
48
49
        return Command::SUCCESS;
50
    }
51
}
52