Code Duplication    Length = 7-9 lines in 2 locations

app/Http/Controllers/AssociationController.php 1 location

@@ 69-75 (lines=7) @@
66
                $request->merge(['president_id' => null]);
67
68
            $association = Association::create($request->all());
69
            if (Request::ajax()) {
70
                return Response::json(['msg' => trans('msg.association_create_successful', ['name' => $association->name]), 'status' => 'success', 'data' => $association], 200);
71
            } else {
72
                $msg = trans('msg.association_create_successful', ['name' => $association->name]);
73
                flash()->success($msg);
74
                return redirect(route("associations.index"));
75
            }
76
        } catch (QueryException $e) {
77
            if (Request::ajax()) {
78
                return Response::json(['msg' => $e], 500);

app/Http/Controllers/ClubController.php 1 location

@@ 85-93 (lines=9) @@
82
            if ($request->association_id == 0) $request->merge(['association_id' => null]);
83
            $club = Club::create($request->all());
84
85
            if (Request::ajax()) {
86
                return Response::json(['msg' => trans('msg.club_create_successful', ['name' => $club->name]), 'status' => 'success', 'data' => $club], 200);
87
            } else {
88
                $msg = trans('msg.club_edit_successful', ['name' => $club->name]);
89
                flash()->success($msg);
90
91
                return redirect("clubs");
92
93
            }
94
        } catch (QueryException $e) {
95
            $user = User::find($request->president_id);
96
            $msg = trans('msg.club_president_already_exists', ['user' => $user->name]);