ExtendedDatabaseChannel::buildPayload()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 11
rs 10
1
<?php
2
3
namespace App\Notifications;
4
5
use Illuminate\Notifications\Channels\DatabaseChannel;
6
use Illuminate\Notifications\Notification;
7
use Illuminate\Support\Arr;
8
9
class ExtendedDatabaseChannel extends DatabaseChannel
10
{
11
    /**
12
     * Build an array payload for the DatabaseNotification Model.
13
     *
14
     * @param  mixed  $notifiable
15
     * @param  \Illuminate\Notifications\Notification  $notification
16
     * @return array
17
     */
18
    protected function buildPayload($notifiable, Notification $notification)
19
    {
20
        $data = $this->getData($notifiable, $notification);
21
        return [
22
            'id' => $notification->id,
23
            'type' => get_class($notification),
24
            'read_at' => null,
25
26
            'loan_id' => Arr::get($data, 'loan_id'),
27
            'data' => [
28
                'email' => Arr::get($data, 'email'),
29
            ],
30
        ];
31
    }
32
}
33