Passed
Push — master ( 4a474d...df1b75 )
by Stephen
02:14
created

UserNotification   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 13
c 1
b 1
f 0
dl 0
loc 55
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A query() 0 3 1
A newEloquentBuilder() 0 3 1
A user() 0 3 1
A boot() 0 6 1
1
<?php
2
3
namespace Sfneal\Users\Models;
4
5
use Illuminate\Database\Eloquent\Builder;
6
use Illuminate\Database\Eloquent\Relations\BelongsTo;
7
use Sfneal\Models\AbstractModel;
8
use Sfneal\Scopes\CreatedOrderScope;
9
use Sfneal\Users\Builders\UserNotificationBuilder;
10
11
class UserNotification extends AbstractModel
12
{
13
    /**
14
     * The "booting" method of the model.
15
     *
16
     * @return void
17
     */
18
    protected static function boot()
19
    {
20
        parent::boot();
21
22
        // Query scopes
23
        static::addGlobalScope(new CreatedOrderScope());
24
    }
25
26
    protected $connection = 'mysql';
27
    protected $table = 'user_notification';
28
    protected $primaryKey = 'user_notification_id';
29
30
    protected $fillable = [
31
        'user_notification_id',
32
        'user_id',
33
        'type',
34
    ];
35
36
    /**
37
     * Query Builder.
38
     *
39
     * @param $query
40
     *
41
     * @return UserNotificationBuilder
42
     */
43
    public function newEloquentBuilder($query)
44
    {
45
        return new UserNotificationBuilder($query);
46
    }
47
48
    /**
49
     * Custom query Builder.
50
     *
51
     * @return UserNotificationBuilder|Builder
52
     */
53
    public static function query(): UserNotificationBuilder
54
    {
55
        return parent::query();
56
    }
57
58
    /**
59
     * User model this notification subscription belongs to.
60
     *
61
     * @return BelongsTo
62
     */
63
    public function user()
64
    {
65
        return $this->belongsTo(User::class, 'user_id', 'id');
66
    }
67
}
68