LaravelFastComments::commentator()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Axitdev\LaravelFastComments;
4
5
use Exception;
6
use Illuminate\Database\Eloquent\Model;
7
8
class LaravelFastComments extends Model
9
{
10
    /**
11
     * The table associated with the model.
12
     *
13
     * @var string
14
     */
15
    protected $table = 'comments';
16
	
17
	/**
18
     * The attributes that are mass assignable.
19
     *
20
     * @var array
21
     */
22
    protected $fillable = [
23
        'comment', 'user_id',
24
    ];
25
26
    /**
27
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
28
     * @throws Exception
29
     */
30
    public function commentator()
31
    {
32
        return $this->belongsTo($this->getAuthModelName(), 'user_id');
33
    }
34
35
    /**
36
     * @return \Illuminate\Config\Repository|mixed
37
     * @throws Exception
38
     */
39
    protected function getAuthModelName()
40
    {
41
        if (!is_null(config('auth.providers.users.model'))) {
42
            return config('auth.providers.users.model');
43
        }
44
        throw new Exception('Could not determine the commentator model name.');
45
    }
46
}
47