Completed
Push — master ( 78819d...32bab2 )
by Seong
01:18
created

Subscription::threads()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Seongbae\Discuss\Models;
3
4
use Illuminate\Database\Eloquent\Model;
5
use Seongbae\Discuss\Events\NewReply;
6
use Seongbae\Discuss\Events\NewThread;
7
use Auth;
8
9
class Subscription extends Model
10
{
11
    protected $table = 'discuss_subscription';
12
13
    protected $fillable = [
14
        'subscribable_id',
15
        'subscribable_type',
16
        'user_id',
17
        'user_type'
18
    ];
19
20
	public function subscribable()
21
    {
22
        return $this->morphTo();
23
    }
24
25
    public function user()
26
    {
27
        return $this->belongsTo(config('discuss.user_type'));
28
    }
29
30
    public function threads()
31
    {
32
        return $this->morphedByMany(Thread::class, 'subscribable');
33
    }
34
35
    /**
36
     * Get all of the videos that are assigned this tag.
37
     */
38
    public function channels()
39
    {
40
        return $this->morphedByMany(Channel::class, 'subscribable');
41
    }
42
}
43