Completed
Push — master ( 11a0f2...1d683d )
by Karl
10s
created

CustomDatabaseNotification::search()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php namespace JobApis\JobsToMail\Models;
2
3
use Illuminate\Notifications\DatabaseNotification;
4
5
class CustomDatabaseNotification extends DatabaseNotification
6
{
7
    /**
8
     * Defines the relationship to Search model
9
     *
10
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
11
     */
12 1
    public function search()
13
    {
14 1
        return $this->belongsTo(Search::class);
15
    }
16
17
    /**
18
     * Overrides the save method so that search IDs can be added to the Notification
19
     * in the database
20
     *
21
     * @param array $options
22
     */
23 2
    public function save(array $options = [])
24
    {
25
        // Set the jobs and search id into their own fields
26 2
        $data = $this->data;
27 2
        if (isset($data['search_id']) && isset($data['jobs'])) {
28 1
            $this->data = $data['jobs'];
29 1
            $this->search_id = $data['search_id'];
30
        }
31 2
        parent::save();
32 2
    }
33
}
34