Add all files

This commit is contained in:
root
2025-11-30 11:57:22 +01:00
parent 2ee51cac4f
commit 044271db3d
1476 changed files with 142544 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
<?php
namespace Paymenter\Extensions\Others\Security\Models;
use Illuminate\Database\Eloquent\Model;
class LoginAttempt extends Model
{
protected $table = 'ext_security_login_attempts';
protected $fillable = [
'ip_address',
'email',
'successful',
'user_agent',
'country',
'notes',
'attempted_at',
];
protected $casts = [
'successful' => 'boolean',
'attempted_at' => 'datetime',
];
/**
* Record a login attempt
*/
public static function recordAttempt(
string $ipAddress,
?string $email = null,
bool $successful = false,
?string $userAgent = null,
?string $country = null,
?string $notes = null
): self {
return static::create([
'ip_address' => $ipAddress,
'email' => $email,
'successful' => $successful,
'user_agent' => $userAgent,
'country' => $country,
'notes' => $notes,
'attempted_at' => now(),
]);
}
/**
* Get recent failed attempts for an IP
*/
public static function getRecentFailedAttempts(string $ipAddress, int $minutes = 60): int
{
return static::where('ip_address', $ipAddress)
->where('successful', false)
->where('attempted_at', '>', now()->subMinutes($minutes))
->count();
}
/**
* Get recent failed attempts for an email
*/
public static function getRecentFailedAttemptsForEmail(string $email, int $minutes = 60): int
{
return static::where('email', $email)
->where('successful', false)
->where('attempted_at', '>', now()->subMinutes($minutes))
->count();
}
}