callAddApprovedStudents::handle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Console\Commands;
4
5
use App\Models\Institution;
6
use Illuminate\Console\Command;
7
8
class callAddApprovedStudents extends Command
9
{
10
    /**
11
     * The name and signature of the console command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'admission:run';
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
        $this->instituions = new Institution();
0 ignored issues
show
Bug Best Practice introduced by
The property instituions does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
33
    }
34
35
    /**
36
     * Execute the console command.
37
     *
38
     * @return mixed
39
     */
40
    public function handle()
41
    {
42
        ini_set('memory_limit','2048');
43
        $institutions = $this->instituions->all()->chunk(50)->toArray();
44
        array_walk($institutions,array($this,'addInstitutionStudents'));
45
    }
46
47
    protected function addInstitutionStudents($chunk){
48
        array_walk($chunk,array($this,'callFunction'));
49
50
    }
51
52
    protected function callFunction($institution){
53
        $this->call('admission:students',['institution' => $institution['code']]);
54
    }
55
}
56