Code Duplication    Length = 23-23 lines in 2 locations

src/Http/Controllers/StudiesController.php 2 locations

@@ 57-79 (lines=23) @@
54
     *
55
     * @return \Illuminate\Http\Response
56
     */
57
    public function store(StudyCreateRequest $request)
58
    {
59
        try {
60
            $this->validator->with($request->all())->passesOrFail(ValidatorInterface::RULE_CREATE);
61
            $study = $this->repository->create($request->all());
62
            $response = [
63
                'message' => 'Study created.',
64
                'data'    => $study->toArray(),
65
            ];
66
            if ($request->wantsJson()) {
67
                return response()->json($response);
68
            }
69
70
            return redirect()->back()->with('message', $response['message']);
71
        } catch (ValidatorException $e) {
72
            if ($request->wantsJson()) {
73
                return response()->json([
74
                    'error'   => true,
75
                    'message' => $e->getMessageBag(),
76
                ]);
77
            }
78
79
            return redirect()->back()->withErrors($e->getMessageBag())->withInput();
80
        }
81
    }
82
@@ 124-146 (lines=23) @@
121
     *
122
     * @return Response
123
     */
124
    public function update(StudyUpdateRequest $request, $id)
125
    {
126
        try {
127
            $this->validator->with($request->all())->passesOrFail(ValidatorInterface::RULE_UPDATE);
128
            $study = $this->repository->update($id, $request->all());
129
            $response = [
130
                'message' => 'Study updated.',
131
                'data'    => $study->toArray(),
132
            ];
133
            if ($request->wantsJson()) {
134
                return response()->json($response);
135
            }
136
137
            return redirect()->back()->with('message', $response['message']);
138
        } catch (ValidatorException $e) {
139
            if ($request->wantsJson()) {
140
                return response()->json([
141
                    'error'   => true,
142
                    'message' => $e->getMessageBag(),
143
                ]);
144
            }
145
146
            return redirect()->back()->withErrors($e->getMessageBag())->withInput();
147
        }
148
    }
149