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
![]() |
|||
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 |