This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Bantenprov\PassingGrade\Http\Controllers; |
||
4 | |||
5 | /* Require */ |
||
6 | use App\Http\Controllers\Controller; |
||
7 | use Illuminate\Http\Request; |
||
8 | use Illuminate\Support\Facades\DB; |
||
9 | use Bantenprov\PassingGrade\Facades\PassingGradeFacade; |
||
10 | |||
11 | /* Models */ |
||
12 | use Bantenprov\Sekolah\Models\Bantenprov\Sekolah\Sekolah; |
||
13 | use Bantenprov\Siswa\Models\Bantenprov\Siswa\Siswa; |
||
14 | use App\User; |
||
15 | use Bantenprov\Sekolah\Models\Bantenprov\Sekolah\AdminSekolah; |
||
16 | |||
17 | /* Etc */ |
||
18 | use Validator; |
||
19 | use Auth; |
||
20 | |||
21 | /** |
||
22 | * The PassingGradeController class. |
||
23 | * |
||
24 | * @package Bantenprov\PassingGrade |
||
25 | * @author bantenprov <[email protected]> |
||
26 | */ |
||
27 | class PassingGradeController extends Controller |
||
28 | { |
||
29 | protected $sekolah; |
||
30 | protected $user; |
||
31 | protected $admin_sekolah; |
||
32 | protected $user_id; |
||
33 | |||
34 | /** |
||
35 | * Create a new controller instance. |
||
36 | * |
||
37 | * @return void |
||
0 ignored issues
–
show
|
|||
38 | */ |
||
39 | public function __construct() |
||
40 | { |
||
41 | $this->sekolah = new Sekolah; |
||
42 | $this->siswa = new Siswa; |
||
43 | $this->user = new User; |
||
44 | $this->user_id = isset(Auth::User()->id) ? $this->user_id : null; |
||
45 | $this->admin_sekolah = AdminSekolah::where('admin_sekolah_id', Auth::User()->id)->first(); |
||
46 | $this->admin_sekolah_id = isset($this->admin_sekolah->sekolah_id) ? $this->admin_sekolah->sekolah_id : null; |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * Display a listing of the resource. |
||
51 | * |
||
52 | * @return \Illuminate\Http\Response |
||
53 | */ |
||
54 | public function index(Request $request) |
||
55 | { |
||
56 | View Code Duplication | if (request()->has('sort')) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
57 | list($sortCol, $sortDir) = explode('|', request()->sort); |
||
58 | |||
59 | $query = $this->sekolah |
||
60 | ->orderBy($sortCol, $sortDir); |
||
61 | } else { |
||
62 | $query = $this->sekolah |
||
63 | ->orderBy('npsn', 'asc'); |
||
64 | } |
||
65 | |||
66 | if ($request->exists('filter')) { |
||
67 | $query->where(function($q) use($request) { |
||
68 | $value = "%{$request->filter}%"; |
||
69 | |||
70 | if (Auth::User()->hasRole(['superadministrator'])) { |
||
71 | $q->where('nama', 'like', $value) |
||
72 | ->orWhere('npsn', 'like', $value); |
||
73 | } else { |
||
74 | $q->where('nama', 'like', $value) |
||
75 | ->orWhere('npsn', 'like', $value); |
||
76 | } |
||
77 | }); |
||
78 | } |
||
79 | |||
80 | if (Auth::User()->hasRole(['superadministrator'])) { |
||
0 ignored issues
–
show
This
if statement is empty and can be removed.
This check looks for the bodies of These if (rand(1, 6) > 3) {
//print "Check failed";
} else {
print "Check succeeded";
}
could be turned into if (rand(1, 6) <= 3) {
print "Check succeeded";
}
This is much more concise to read. ![]() |
|||
81 | // |
||
82 | } else { |
||
83 | $query->where('id', $this->admin_sekolah_id); |
||
84 | } |
||
85 | |||
86 | $perPage = request()->has('per_page') ? (int) request()->per_page : null; |
||
87 | $response = $query->with(['jenis_sekolah', 'province', 'city', 'district', 'village', 'master_zona', 'user'])->paginate($perPage); |
||
88 | |||
89 | if (is_null($this->admin_sekolah) && !Auth::User()->hasRole(['superadministrator'])) { |
||
0 ignored issues
–
show
This
if statement is empty and can be removed.
This check looks for the bodies of These if (rand(1, 6) > 3) {
//print "Check failed";
} else {
print "Check succeeded";
}
could be turned into if (rand(1, 6) <= 3) {
print "Check succeeded";
}
This is much more concise to read. ![]() |
|||
90 | // $response = (object) []; |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
91 | } else { |
||
0 ignored issues
–
show
This
else statement is empty and can be removed.
This check looks for the These if (rand(1, 6) > 3) {
print "Check failed";
} else {
//print "Check succeeded";
}
could be turned into if (rand(1, 6) > 3) {
print "Check failed";
}
This is much more concise to read. ![]() |
|||
92 | // |
||
93 | } |
||
94 | |||
95 | return response()->json($response) |
||
96 | ->header('Access-Control-Allow-Origin', '*') |
||
97 | ->header('Access-Control-Allow-Methods', 'GET'); |
||
98 | } |
||
99 | |||
100 | /** |
||
101 | * Display the specified resource. |
||
102 | * |
||
103 | * @param \App\Sekolah $sekolah |
||
0 ignored issues
–
show
There is no parameter named
$sekolah . Was it maybe removed?
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. Consider the following example. The parameter /**
* @param array $germany
* @param array $island
* @param array $italy
*/
function finale($germany, $island) {
return "2:1";
}
The most likely cause is that the parameter was removed, but the annotation was not. ![]() |
|||
104 | * @return \Illuminate\Http\Response |
||
105 | */ |
||
106 | public function show($id, $track = null, Request $request) |
||
107 | { |
||
108 | View Code Duplication | if (request()->has('sort')) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
109 | list($sortCol, $sortDir) = explode('|', request()->sort); |
||
110 | |||
111 | $query = $this->siswa->orderBy($sortCol, $sortDir); |
||
112 | } else { |
||
113 | $query = $this->siswa |
||
114 | ->orderBy('nomor_un', 'asc'); |
||
115 | } |
||
116 | |||
117 | if ($request->exists('filter')) { |
||
118 | $query->where(function($q) use($request) { |
||
119 | $value = "%{$request->filter}%"; |
||
120 | |||
121 | if (Auth::User()->hasRole(['superadministrator'])) { |
||
122 | $q->where('nomor_un', 'like', $value) |
||
123 | ->orWhere('nik', 'like', $value) |
||
124 | ->orWhere('nama_siswa', 'like', $value) |
||
125 | ->orWhere('no_kk', 'like', $value) |
||
126 | ->orWhere('nisn', 'like', $value); |
||
127 | } else { |
||
128 | $q->where('nomor_un', 'like', $value) |
||
129 | ->orWhere('nik', 'like', $value) |
||
130 | ->orWhere('nama_siswa', 'like', $value) |
||
131 | ->orWhere('no_kk', 'like', $value) |
||
132 | ->orWhere('nisn', 'like', $value); |
||
133 | } |
||
134 | }); |
||
135 | } |
||
136 | |||
137 | if (Auth::User()->hasRole(['superadministrator'])) { |
||
0 ignored issues
–
show
This
if statement is empty and can be removed.
This check looks for the bodies of These if (rand(1, 6) > 3) {
//print "Check failed";
} else {
print "Check succeeded";
}
could be turned into if (rand(1, 6) <= 3) {
print "Check succeeded";
}
This is much more concise to read. ![]() |
|||
138 | // |
||
139 | } else { |
||
140 | $query->where('sekolah_id', $this->admin_sekolah_id); |
||
141 | } |
||
142 | |||
143 | if ($track == 'umum') { |
||
144 | $query->whereIn('kegiatan_id', ['12', '22']); |
||
145 | } else if ($track == 'prestasi') { |
||
146 | $query->whereIn('kegiatan_id', ['11', '21']); |
||
147 | } |
||
148 | |||
149 | $perPage = request()->has('per_page') ? (int) request()->per_page : null; |
||
150 | $response = $query->with(['province', 'city', 'district', 'village', 'sekolah', 'prodi_sekolah', 'user', 'akademik', 'nilai'])->paginate($perPage); |
||
151 | |||
152 | if (is_null($this->admin_sekolah) && !Auth::User()->hasRole(['superadministrator'])) { |
||
0 ignored issues
–
show
This
if statement is empty and can be removed.
This check looks for the bodies of These if (rand(1, 6) > 3) {
//print "Check failed";
} else {
print "Check succeeded";
}
could be turned into if (rand(1, 6) <= 3) {
print "Check succeeded";
}
This is much more concise to read. ![]() |
|||
153 | // $response = (object) []; |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
154 | } else { |
||
0 ignored issues
–
show
This
else statement is empty and can be removed.
This check looks for the These if (rand(1, 6) > 3) {
print "Check failed";
} else {
//print "Check succeeded";
}
could be turned into if (rand(1, 6) > 3) {
print "Check failed";
}
This is much more concise to read. ![]() |
|||
155 | // |
||
156 | } |
||
157 | |||
158 | foreach ($response as $siswa) { |
||
159 | if (isset($siswa->prodi_sekolah->program_keahlian)) { |
||
160 | $siswa->prodi_sekolah->program_keahlian; |
||
161 | } |
||
162 | } |
||
163 | |||
164 | return response()->json($response) |
||
165 | ->header('Access-Control-Allow-Origin', '*') |
||
166 | ->header('Access-Control-Allow-Methods', 'GET'); |
||
167 | } |
||
168 | } |
||
169 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.