diff options
author | Sam Light <samlight1994@gmail.com> | 2025-07-17 22:21:53 +0100 |
---|---|---|
committer | Sam Light <samlight1994@gmail.com> | 2025-07-17 22:21:53 +0100 |
commit | ff9d08e258b7032c09550ff4b21fee52ac6e5e05 (patch) | |
tree | 493f6bd4efc24a0c3ff2d443fbc055816aaa4948 | |
parent | 886b0d0a5fe9df7f92c9a91e961f58607febe2ea (diff) |
Last login attribute improvements
-rw-r--r-- | src/HasAuthLogs.php | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/HasAuthLogs.php b/src/HasAuthLogs.php index 543b580..01aa768 100644 --- a/src/HasAuthLogs.php +++ b/src/HasAuthLogs.php @@ -1,4 +1,4 @@ -<?php +q<?php namespace Lightscale\LaralightAuthLog; @@ -8,9 +8,13 @@ use Lightscale\LaralightAuthLog\Enums\Status; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\Casts\Attribute; +use Illuminate\Support\Carbon; use DateTimeInterface; +/** + * @property-read ?Carbon $last_login + */ trait HasAuthLogs { @@ -31,10 +35,10 @@ trait HasAuthLogs return $this->successfulAuthLogs()->one(); } - public function lastLogin(): Attribute + protected function lastLogin(): Attribute { return Attribute::get( - fn(): ?DateTimeInterface => $this->successfulAuthLog?->created_at + fn(): ?Carbon => $this->successfulAuthLog?->created_at ); } |