moe-lk /
bulk-upload
| 1 | <?php |
||
| 2 | |||
| 3 | namespace App\Console\Commands; |
||
| 4 | |||
| 5 | use Illuminate\Console\Command; |
||
| 6 | use App\Models\Student_guardian; |
||
| 7 | use Illuminate\Support\Facades\DB; |
||
| 8 | |||
| 9 | class RemoveDuplicatedGuardians extends Command |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * The name and signature of the console command. |
||
| 13 | * |
||
| 14 | * @var string |
||
| 15 | */ |
||
| 16 | protected $signature = 'clean:guardian'; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * The console command description. |
||
| 20 | * |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | protected $description = 'Command description'; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Create a new command instance. |
||
| 27 | * |
||
| 28 | * @return void |
||
| 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 | try { |
||
| 43 | $this->start_time = microtime(TRUE); |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 44 | $this->output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
||
|
0 ignored issues
–
show
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...
|
|||
| 45 | $this->output->writeln('############### Starting delete Duplication ################'); |
||
| 46 | Student_guardian::withTrashed()->restore(); |
||
| 47 | $this->delete(); |
||
| 48 | $this->end_time = microtime(TRUE); |
||
|
0 ignored issues
–
show
|
|||
| 49 | $this->output->writeln('The cook took ' . ($this->end_time - $this->start_time) . ' seconds to complete'); |
||
| 50 | } catch (\Throwable $th) { |
||
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
|
|||
| 51 | } |
||
| 52 | } |
||
| 53 | |||
| 54 | public function delete(){ |
||
| 55 | try{ |
||
| 56 | DB::statement("UPDATE student_guardians t1 |
||
| 57 | INNER JOIN student_guardians t2 |
||
| 58 | set t1.deleted_at=now() |
||
| 59 | WHERE |
||
| 60 | t1.id > t2.id AND |
||
| 61 | t1.student_id = t2.student_id AND |
||
| 62 | t1.guardian_id = t2.guardian_id"); |
||
| 63 | }catch(\Exception $e){ |
||
| 64 | dd($e); |
||
| 65 | } |
||
| 66 | } |
||
| 67 | } |
||
| 68 |