Passed
Pull Request — master (#33)
by
unknown
09:22 queued 04:40
created

AuthenticationLog   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

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

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
     * Get the table associated with the model.
50
     *
51
     * @return string
52
     */
53
    public function getTable()
54
    {
55
        return config('authentication-log.table_name', parent::getTable());
56
    }
57
}
58