Login   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 36
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A user() 0 4 1
A device() 0 6 1
1
<?php
2
3
namespace Lab404\AuthChecker\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\Relations\BelongsTo;
7
use Illuminate\Database\Eloquent\Relations\MorphTo;
8
9
/**
10
 * @package Lab404\AuthChecker\Models
11
 * @property int $id
12
 * @property \Lab404\AuthChecker\Models\Device $device
13
 * @property int $device_id
14
 * @property \Illuminate\Contracts\Auth\Authenticatable $user
15
 * @property int $user_id
16
 * @property string $user_type
17
 * @property string $ip_address
18
 * @property \Carbon\Carbon $created_at
19
 * @property \Carbon\Carbon $updated_at
20
 */
21
class Login extends Model
22
{
23
    /** @var string */
24
    const TYPE_LOGIN = 'auth';
25
    const TYPE_FAILED = 'failed';
26
    const TYPE_LOCKOUT = 'lockout';
27
    /** @var array $with */
28
    protected $with = ['device'];
29
    /** @var array $casts */
30
    protected $casts = [
31
        'user_id' => 'integer',
32
        'user_type' => 'string',
33
        'device_id' => 'integer',
34
        'ip_address' => 'string',
35
    ];
36
    /** @var array $fillable */
37
    protected $fillable = [
38
        'user_id',
39
        'user_type',
40
        'ip_address',
41
        'created_at',
42
        'type',
43
    ];
44
45
    public function user(): MorphTo
46
    {
47
        return $this->morphTo();
48
    }
49
50
    public function device(): BelongsTo
51
    {
52
        $model = config('auth-checker.models.device') ?? Device::class;
53
54
        return $this->belongsTo($model);
55
    }
56
}
57