Passed
Push — 5.0.0 ( f07a46...357374 )
by Fèvre
05:39
created

DiscussUser::conversation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Xetaravel\Models;
6
7
use Eloquence\Behaviours\CountCache\CountedBy;
8
use Eloquence\Behaviours\CountCache\HasCounts;
9
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
10
use Illuminate\Database\Eloquent\Relations\BelongsTo;
11
use Xetaravel\Observers\DiscussUserObserver;
12
13
#[ObservedBy([DiscussUserObserver::class])]
14
class DiscussUser extends Model
15
{
16
    use HasCounts;
17
18
    /**
19
     * The attributes that are mass assignable.
20
     *
21
     * @var array
22
     */
23
    protected $fillable = [
24
        'user_id',
25
        'conversation_id'
26
    ];
27
28
    /**
29
     * Get the user that owns the user.
30
     *
31
     * @return BelongsTo
32
     */
33
    public function user(): BelongsTo
34
    {
35
        return $this->belongsTo(User::class);
36
    }
37
38
    /**
39
     * Get the conversation that owns the user.
40
     *
41
     * @return BelongsTo
42
     */
43
    #[CountedBy(as: 'user_count')]
44
    public function conversation(): BelongsTo
45
    {
46
        return $this->belongsTo(DiscussConversation::class);
47
    }
48
}
49