Completed
Push — version-4 ( 5bb021 )
by
unknown
08:16
created

NotificationCategory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 5
Bugs 3 Features 1
Metric Value
c 5
b 3
f 1
dl 0
loc 25
rs 10
wmc 2
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A notifications() 0 6 1
A categories() 0 9 1
1
<?php
2
3
namespace Fenos\Notifynder\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class NotificationCategory extends Model
8
{
9
    protected $table = 'notification_categories';
10
11
    protected $fillable = ['name', 'text'];
12
13
    public $timestamps = false;
14
15
    public function notifications()
16
    {
17
        $config = app('notifynder.config');
18
        $model = $config->getNotificationModel();
19
        return $this->hasMany($model, 'category_id');
20
    }
21
22
    public function categories()
23
    {
24
        return $this->belongsToMany(
25
            NotificationGroup::class,
26
            'notifications_categories_in_groups',
27
            'category_id',
28
            'group_id'
29
        );
30
    }
31
}
32