Add authentication log cleaning and associated tests

This commit is contained in:
Bubka
2024-05-24 13:50:19 +02:00
parent a9b1a20f30
commit e73fbf658f
5 changed files with 180 additions and 5 deletions

View File

@ -28,6 +28,24 @@ class AuthLogFactory extends Factory
];
}
/**
* Indicate that the model has login before last year.
*
* @return \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\AuthLog>
*/
public function daysAgo(int $days)
{
return $this->state(function (array $attributes) use ($days) {
$loginDate = now()->subDays($days);
$logoutDate = $loginDate->addHours(1);
return [
'login_at' => $loginDate,
'logout_at' => $logoutDate,
];
});
}
/**
* Indicate that the model is a failed login.
*