UserLoginLog   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 29
ccs 4
cts 4
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A loggable() 0 3 1
A getDeviceTypeAttribute() 0 3 1
1
<?php
2
3
namespace Moecasts\Laravel\UserLoginLog\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\Relations\MorphTo;
7
use Moecasts\Laravel\UserLoginLog\DeviceType;
8
9
class UserLoginLog extends Model
10
{
11
    public $timestamps = false;
12
13
    protected $table = 'user_login_logs';
14
15
    protected $fillable = [
16
        'ip',
17
        'device',
18
        'platform',
19
        'platform_version',
20
        'browser',
21
        'browser_version',
22
        'device_type',
23
        'login_at',
24
    ];
25
26
    protected $casts = [
27
        'login_at' => 'datetime',
28
    ];
29
30 1
    public function loggable(): MorphTo
31
    {
32 1
        return $this->morphTo();
33
    }
34
35 1
    public function getDeviceTypeAttribute($value)
36
    {
37 1
        return DeviceType::getType($value);
38
    }
39
}
40