for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace KeyShang\AuthenticationLog;
use Illuminate\Database\Eloquent\Concerns\HasRelationships;
use Illuminate\Database\Eloquent\Relations\MorphMany;
trait AuthenticationLogable
{
/**
* Get the entity's authentications.
*/
public function authentications(): MorphMany
/** @var HasRelationships $this */
return $this->morphMany(AuthenticationLog::class, 'authenticatable')->latest('login_at');
}
* The Authentication Log notifications delivery channels.
public function notifyAuthenticationLogVia(): array
return ['mail'];
* Get the entity's last login at.
public function lastLoginAt()
return optional($this->authentications()->first())->login_at;
* Get the entity's last login ip address.
public function lastLoginIp()
return optional($this->authentications()->first())->ip_address;
* Get the entity's previous login at.
public function previousLoginAt()
return optional($this->authentications()->skip(1)->first())->login_at;
* Get the entity's previous login ip.
public function previousLoginIp()
return optional($this->authentications()->skip(1)->first())->ip_address;