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

NotificationCategory::categories()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 9
rs 9.6666
cc 1
eloc 6
nc 1
nop 0
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