Code Duplication    Length = 20-20 lines in 2 locations

src/Controllers/UsersController.php 2 locations

@@ 668-687 (lines=20) @@
665
            }
666
667
            // is new image uploaded?
668
            if ($file = Input::file('pic'))
669
            {
670
                $fileName        = $file->getClientOriginalName();
671
                $extension       = $file->getClientOriginalExtension() ?: 'png';
672
673
                if ($extension == 'png' || $extension == 'PNG' || $extension == 'JGP' || $extension == 'jpg' || $extension == 'gif')
674
                {
675
                    $folderName      = '/uploads/users/';
676
                    $destinationPath = public_path() . $folderName;
677
                    $safeName        = str_random(10).'.'.$extension;
678
                    $file->move($destinationPath, $safeName);
679
680
                    //delete old pic if exists
681
                    if(File::exists(public_path() . $folderName . $user->pic))
682
                        File::delete(public_path() . $folderName . $user->pic);
683
684
                    //save new file path into db
685
                    $user->pic   = $safeName;
686
                }
687
            }
688
689
            /*
690
            // Get the current user groups
@@ 843-862 (lines=20) @@
840
                $user->force_new_password = 0;
841
842
            // is new image uploaded?
843
            if ($file = Input::file('pic'))
844
            {
845
                $fileName        = $file->getClientOriginalName();
846
                $extension       = $file->getClientOriginalExtension() ?: 'png';
847
848
                if ($extension == 'png' || $extension == 'PNG' || $extension == 'JGP' || $extension == 'jpg' || $extension == 'gif')
849
                {
850
                    $folderName      = '/uploads/users/';
851
                    $destinationPath = public_path() . $folderName;
852
                    $safeName        = str_random(10).'.'.$extension;
853
                    $file->move($destinationPath, $safeName);
854
855
                    //delete old pic if exists
856
                    if(File::exists(public_path() . $folderName . $user->pic))
857
                        File::delete(public_path() . $folderName . $user->pic);
858
859
                    //save new file path into db
860
                    $user->pic   = $safeName;
861
                }
862
            }
863
864
            $user->save();
865