Issues (5)

src/AuthenticationLogable.php (1 issue)

1
<?php
2
3
namespace Yadahan\AuthenticationLog;
4
5
trait AuthenticationLogable
6
{
7
    /**
8
     * Get the entity's authentications.
9
     */
10
    public function authentications()
11
    {
12
        return $this->morphMany(AuthenticationLog::class, 'authenticatable')->latest('login_at');
0 ignored issues
show
It seems like morphMany() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

12
        return $this->/** @scrutinizer ignore-call */ morphMany(AuthenticationLog::class, 'authenticatable')->latest('login_at');
Loading history...
13
    }
14
15
    /**
16
     * The Authentication Log notifications delivery channels.
17
     *
18
     * @return array
19
     */
20
    public function notifyAuthenticationLogVia()
21
    {
22
        return ['mail'];
23
    }
24
25
    /**
26
     * Get the entity's last login at.
27
     */
28
    public function lastLoginAt()
29
    {
30
        return optional($this->authentications()->first())->login_at;
31
    }
32
33
    /**
34
     * Get the entity's last login ip address.
35
     */
36
    public function lastLoginIp()
37
    {
38
        return optional($this->authentications()->first())->ip_address;
39
    }
40
41
    /**
42
     * Get the entity's previous login at.
43
     */
44
    public function previousLoginAt()
45
    {
46
        return optional($this->authentications()->skip(1)->first())->login_at;
47
    }
48
49
    /**
50
     * Get the entity's previous login ip.
51
     */
52
    public function previousLoginIp()
53
    {
54
        return optional($this->authentications()->skip(1)->first())->ip_address;
55
    }
56
}
57