Code Duplication    Length = 15-16 lines in 2 locations

app/Http/Controllers/ExchangeController.php 2 locations

@@ 31-45 (lines=15) @@
28
     *
29
     * @return \Illuminate\Http\Response
30
     */
31
    public function confirm($id)
32
    {
33
        $exchange = DB::transaction(function () use ($id) {
34
            $exchange = Exchange::findOrFail($id);
35
            $this->checkDecideAuthorization($exchange);
36
37
            return $exchange->perform();
38
        });
39
40
        flash('The shift exchange request was successfully confirmed.')->success();
41
        Mail::to($exchange->fromStudent()->user)
42
            ->send(new ConfirmedExchangeNotification($exchange));
43
44
        return redirect()->back();
45
    }
46
47
    /**
48
     * Store a decline of an exchange in storage.
@@ 54-69 (lines=16) @@
51
     *
52
     * @return \Illuminate\Http\Response
53
     */
54
    public function decline($id)
55
    {
56
        $exchange = DB::transaction(function () use ($id) {
57
            $exchange = Exchange::findOrFail($id);
58
            $this->checkDecideAuthorization($exchange);
59
            $exchange->delete();
60
61
            return $exchange;
62
        });
63
64
        flash('The shift exchange request was successfully declined.')->success();
65
        Mail::to($exchange->fromStudent()->user)
66
            ->send(new DeclinedExchangeNotification($exchange));
67
68
        return redirect()->back();
69
    }
70
71
    /**
72
     * Checks authorization of the authenticated user to decide on the given exchange.