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

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