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

DiscussUser   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 34
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A conversation() 0 4 1
A user() 0 3 1
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