Passed
Pull Request — master (#33)
by
unknown
07:20
created

AuthenticationLog   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A authenticatable() 0 3 1
A getTable() 0 3 1
1
<?php
2
3
namespace Yadahan\AuthenticationLog;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class AuthenticationLog extends Model
8
{
9
    /**
10
     * The table associated with the model.
11
     *
12
     * @var string
13
     */
14
    protected $table = 'authentication_log';
15
16
    /**
17
     * Indicates if the model should be timestamped.
18
     *
19
     * @var bool
20
     */
21
    public $timestamps = false;
22
23
    /**
24
     * The attributes that aren't mass assignable.
25
     *
26
     * @var array
27
     */
28
    protected $guarded = ['authenticatable_id', 'authenticatable_type'];
29
30
    /**
31
     * The attributes that should be cast to native types.
32
     *
33
     * @var array
34
     */
35
    protected $casts = [
36
        'login_at' => 'datetime',
37
        'logout_at' => 'datetime',
38
    ];
39
40
    /**
41
     * Get the authenticatable entity that the authentication log belongs to.
42
     */
43
    public function authenticatable()
44
    {
45
        return $this->morphTo();
46
    }
47
48
49
    /**
50
     * Get the table associated with the model.
51
     *
52
     * @return string
53
     */
54
    public function getTable()
55
    {
56
        return config('authentication-log.table_name', parent::getTable());
57
    }
58
}
59