Issues (367)

app/Console/Commands/PromoteStudents.php (6 issues)

1
<?php
2
3
namespace App\Console\Commands;
4
5
use App\Http\Controllers\BulkPromotion;
6
use Webpatser\Uuid\Uuid;
7
use App\Institution_grade;
0 ignored issues
show
The type App\Institution_grade was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use App\Models\Institution;
9
use App\Models\Academic_period;
10
use App\Models\Education_grade;
11
use Illuminate\Console\Command;
12
use App\Models\Institution_class;
13
use Illuminate\Support\Facades\DB;
14
use App\Models\Institution_student;
15
use App\Models\Institution_subject;
16
use Illuminate\Support\Facades\Log;
17
use App\Models\Institution_class_student;
18
use App\Models\Institution_class_subject;
19
use App\Models\Institution_subject_student;
20
use App\Models\Institution_student_admission;
21
22
/**
23
 * Class PromoteStudents
24
 * @package App\Console\Commands
25
 */
26
class PromoteStudents extends Command
27
{
28
    /**
29
     * The name and signature of the console command.
30
     *
31
     * @var string
32
     */
33
    protected $signature = 'promote:students  {institution} {year} {mode}';
34
35
    /**
36
     * The console command description.
37
     *
38
     * @var string
39
     */
40
    protected $description = 'Promote students';
41
42
    /**
43
     * Create a new command instance.
44
     *
45
     * @return void
46
     */
47
    public function __construct()
48
    {
49
        parent::__construct();
50
        $this->instituion_grade = new \App\Models\Institution_grade();
0 ignored issues
show
Bug Best Practice introduced by
The property instituion_grade does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
51
        $this->academic_period = new Academic_period();
0 ignored issues
show
Bug Best Practice introduced by
The property academic_period does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
52
    }
53
54
55
56
    /**
57
     * Execute the console command.
58
     *
59
     * @return mixed
60
     */
61
    public function handle()
62
    {
63
        $output = new \Symfony\Component\Console\Output\ConsoleOutput();
64
        $year = $this->argument('year');
65
        $institution = $this->argument('institution');
66
        $academicPeriod = $this->academic_period->getAcademicPeriod($year);
67
        $previousAcademicPeriodYear = $academicPeriod->order;
0 ignored issues
show
The property order does not seem to exist on App\Models\Academic_period. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
68
        $previousAcademicPeriod = Academic_period::where('order',$previousAcademicPeriodYear+1)->first();
69
        $mode = $this->argument('mode');
70
        $institutionGrade = $this->instituion_grade->getInstitutionGradeToPromoted($previousAcademicPeriod->code,$institution,$mode);
0 ignored issues
show
The property code does not seem to exist on App\Models\Academic_period. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
71
        $output->writeln('Start promoting:'.$institution);
0 ignored issues
show
Are you sure $institution of type array|null|string can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

71
        $output->writeln('Start promoting:'./** @scrutinizer ignore-type */ $institution);
Loading history...
72
        $params = [
73
            'academicPeriod' => $academicPeriod,
74
            'previousAcademicPeriod' => $previousAcademicPeriod
75
        ];
76
        (new BulkPromotion())->callback($institutionGrade,$params);
77
        $output->writeln('Finished promoting:'.$institution);
78
    }
79
}
80