Files
alrahma_sunday_school_api/app/Models/IpAttempt.php
T
root e13df69885
API CI/CD / Validate (composer + pint) (push) Successful in 3m6s
API CI/CD / Test (PHPUnit) (push) Failing after 4m53s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Security audit (push) Failing after 59s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
fix unittests issues
2026-07-07 20:56:32 -04:00

51 lines
1.2 KiB
PHP

<?php
namespace App\Models;
class IpAttempt extends BaseModel
{
protected $table = 'ip_attempts';
// ✅ legacy: useTimestamps = true (created_at/updated_at)
public $timestamps = true;
protected $fillable = ['ip_address', 'attempts', 'last_attempt_at', 'blocked_until', 'created_at', 'updated_at', 'school_year', 'semester'];
protected $casts = [
'attempts' => 'integer',
'last_attempt_at' => 'datetime',
'blocked_until' => 'datetime',
];
/**
* Equivalent of legacy getAttemptByIp()
*/
public static function getAttemptByIp(string $ip): ?self
{
return static::query()
->where('ip_address', $ip)
->first();
}
/**
* Equivalent of legacy updateIpAttempt()
*/
public static function updateIpAttempt(string $ip, array $data): bool
{
return static::query()
->where('ip_address', $ip)
->update($data) >= 0;
}
/**
* Equivalent of legacy insertIpAttempt()
* Returns inserted id.
*/
public static function insertIpAttempt(array $data): int
{
$row = static::query()->create($data);
return (int) $row->id;
}
}