Code Duplication    Length = 49-49 lines in 2 locations

src/Http/Controllers/AkademikController.php 1 location

@@ 246-294 (lines=49) @@
243
     * @param  \App\Nilai  $nilai
244
     * @return \Illuminate\Http\Response
245
     */
246
    public function edit($id)
247
    {
248
        $user_id        = isset(Auth::User()->id) ? Auth::User()->id : null;
249
        $akademik       = $this->akademik->with(['siswa', 'user'])->findOrFail($id);
250
        $siswas         = $this->siswa->getAttributes();
251
        $users          = $this->user->getAttributes();
252
        $users_special  = $this->user->all();
253
        $users_standar  = $this->user->findOrFail($user_id);
254
        $current_user   = Auth::User();
255
256
        if ($akademik->siswa !== null) {
257
            array_set($akademik->siswa, 'label', $akademik->siswa->nomor_un.' - '.$akademik->siswa->nama_siswa);
258
        }
259
260
        $role_check = Auth::User()->hasRole(['superadministrator','administrator']);
261
262
        if ($akademik->user !== null) {
263
            array_set($akademik->user, 'label', $akademik->user->name);
264
        }
265
266
        if ($role_check) {
267
            $user_special = true;
268
269
            foreach($users_special as $user){
270
                array_set($user, 'label', $user->name);
271
            }
272
273
            $users = $users_special;
274
        } else {
275
            $user_special = false;
276
277
            array_set($users_standar, 'label', $users_standar->name);
278
279
            $users = $users_standar;
280
        }
281
282
        array_set($current_user, 'label', $current_user->name);
283
284
        $response['akademik']       = $akademik;
285
        $response['siswas']         = $siswas;
286
        $response['users']          = $users;
287
        $response['user_special']   = $user_special;
288
        $response['current_user']   = $current_user;
289
        $response['error']          = false;
290
        $response['message']        = 'Success';
291
        $response['status']         = true;
292
293
        return response()->json($response);
294
    }
295
296
    /**
297
     * Update the specified resource in storage.

src/Http/Controllers/NilaiController.php 1 location

@@ 262-310 (lines=49) @@
259
     * @param  \App\Nilai  $nilai
260
     * @return \Illuminate\Http\Response
261
     */
262
    public function edit($id)
263
    {
264
        $user_id        = isset(Auth::User()->id) ? Auth::User()->id : null;
265
        $nilai          = $this->nilai->with(['siswa', 'user'])->findOrFail($id);
266
        $siswas         = $this->siswa->getAttributes();
267
        $users          = $this->user->getAttributes();
268
        $users_special  = $this->user->all();
269
        $users_standar  = $this->user->findOrFail($user_id);
270
        $current_user   = Auth::User();
271
272
        if ($nilai->siswa !== null) {
273
            array_set($nilai->siswa, 'label', $nilai->siswa->nomor_un.' - '.$nilai->siswa->nama_siswa);
274
        }
275
276
        $role_check = Auth::User()->hasRole(['superadministrator','administrator']);
277
278
        if ($nilai->user !== null) {
279
            array_set($nilai->user, 'label', $nilai->user->name);
280
        }
281
282
        if ($role_check) {
283
            $user_special = true;
284
285
            foreach($users_special as $user){
286
                array_set($user, 'label', $user->name);
287
            }
288
289
            $users = $users_special;
290
        } else {
291
            $user_special = false;
292
293
            array_set($users_standar, 'label', $users_standar->name);
294
295
            $users = $users_standar;
296
        }
297
298
        array_set($current_user, 'label', $current_user->name);
299
300
        $response['nilai']          = $nilai;
301
        $response['siswas']         = $siswas;
302
        $response['users']          = $users;
303
        $response['user_special']   = $user_special;
304
        $response['current_user']   = $current_user;
305
        $response['error']          = false;
306
        $response['message']        = 'Success';
307
        $response['status']         = true;
308
309
        return response()->json($response);
310
    }
311
312
    /**
313
     * Update the specified resource in storage.