NotificationsController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 50
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A send() 0 7 1
A create() 0 8 1
A show() 0 7 1
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Loan;
6
use App\Notifications\ExtendedDatabaseNotification;
7
use App\Notifications\FirstReminder;
8
use App\Notifications\ManualReminder;
9
use Illuminate\Http\Request;
10
use Illuminate\Http\Response;
11
use Illuminate\Support\Arr;
12
13
class NotificationsController extends Controller
14
{
15
16
    /**
17
     * Show a reminder.
18
     *
19
     * @param ExtendedDatabaseNotification $notification
20
     * @return Response
21
     */
22
    public function show(ExtendedDatabaseNotification $notification)
23
    {
24
        return response()->view('notifications.show', [
25
            'type' => $notification->humanReadableType(),
26
            'loan' => $notification->loan,
27
            'email' => Arr::get($notification->data, 'email'),
0 ignored issues
show
Bug introduced by
The property data does not seem to exist on App\Notifications\ExtendedDatabaseNotification. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
28
            'sent' => $notification->created_at,
29
        ]);
30
    }
31
32
    /**
33
     * Display a form to create the resource.
34
     *
35
     * @param Loan $loan
36
     * @return Response
37
     */
38
    public function create(Loan $loan)
39
    {
40
        $notification = new FirstReminder($loan);
41
        $email = $notification->email->toArray();
42
43
        return response()->view('notifications.create', array(
44
            'loan' => $loan,
45
            'email' => $email,
46
        ));
47
    }
48
49
    /**
50
     * Sends a new reminder.
51
     *
52
     * @param Loan $loan
53
     * @param Request $request
54
     * @return Response
55
     */
56
    public function send(Loan $loan, Request $request)
57
    {
58
        $loan->user->notify(new ManualReminder($loan, $request->input('subject'), $request->input('body')));
59
60
        return redirect()
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect()->actio... returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
61
            ->action('LoansController@getShow', $loan->id)
62
            ->with('status', 'Påminnelsen ble sendt.');
63
    }
64
}
65