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

NotificationCategory::notifications()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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