Test Setup Failed
Push — master ( 625dac...51086e )
by Mohamed
23:10 queued 15:31
created

ExaminationCheck   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 46
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 14 2
1
<?php
2
3
namespace App\Console\Commands;
4
5
use Illuminate\Console\Command;
6
use Illuminate\Support\Facades\DB;
7
use App\Models\Examination_student;
8
9
class ExaminationCheck extends Command
10
{
11
    /**
12
     * The name and signature of the console command.
13
     *
14
     * @var string
15
     */
16
    protected $signature = 'examination:removedDuplicated';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'check duplications';
24
25
    /**
26
     * Create a new command instance.
27
     *
28
     * @return void
29
     */
30
    public function __construct()
31
    {
32
        parent::__construct();
33
        $this->output = new \Symfony\Component\Console\Output\ConsoleOutput();
0 ignored issues
show
Documentation Bug introduced by
It seems like new Symfony\Component\Co...\Output\ConsoleOutput() of type Symfony\Component\Console\Output\ConsoleOutput is incompatible with the declared type Illuminate\Console\OutputStyle of property $output.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
34
    }
35
36
    /**
37
     * Execute the console command.
38
     *
39
     * @return mixed
40
     */
41
    public function handle()
42
    {
43
       $students = DB::table('examination_students as es')
44
       ->select(DB::raw('count(*) as total'),'e2.*')
45
       ->join('examination_students as e2','es.nsid','e2.nsid')
46
       ->having('total','>',1)
47
       ->groupBy('e2.st_no')
48
       ->orderBy('e2.st_no')
49
        ->get();
50
        $this->output->writeln(count($students).'entries found');
51
52
        foreach($students as $student){
53
            Examination_student::where('st_no',$student->st_no)->update(['nsid'=>'']);
54
            $this->output->writeln($student->st_no.'removed');
55
        }
56
    }
57
}
58