AccessLog::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
ccs 0
cts 6
cp 0
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/*
3
 * This file is part of the Laravel Platfourm package.
4
 *
5
 * (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Longman\Platfourm\Auth\Models\Eloquent;
12
13
use Illuminate\Database\Eloquent\Model;
14
15
class AccessLog extends Model
16
{
17
18
    public $timestamps = false;
19
20
    /**
21
     * The database table used by the model.
22
     *
23
     * @var string
24
     */
25
    protected $table = 'users_access_log';
26
27
    /**
28
     * The attributes that are mass assignable.
29
     *
30
     * @var array
31
     */
32
    protected $fillable = ['user_id', 'scope', 'ip_address', 'user_agent', 'loginas_data'];
33
34
    protected $casts = [
35
        'loginas_data' => 'array',
36
    ];
37
38
    public static function boot()
39
    {
40
        static::creating(function ($model) {
41
            $model->created_at = $model->freshTimestamp();
42
        });
43
    }
44
45
    public function user()
46
    {
47
        return $this->hasOne('App\Models\User');
48
    }
49
50
}
51