Completed
Push — version-4 ( a26cca...5903bf )
by
unknown
02:38
created

NotificationCategory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

3 Methods

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