reconstruction of the project

This commit is contained in:
root
2026-03-08 16:33:24 -04:00
parent 23b7db1107
commit c8de5f7edc
9157 changed files with 77877 additions and 1073823 deletions
+29 -21
View File
@@ -7,7 +7,10 @@ use App\Models\BaseModel;
class IpAttempt extends BaseModel
{
protected $table = 'ip_attempts';
protected $primaryKey = 'id';
// ✅ CI: useTimestamps = true (created_at/updated_at)
public $timestamps = true;
protected $fillable = [
'ip_address',
'attempts',
@@ -19,34 +22,39 @@ class IpAttempt extends BaseModel
'semester',
];
// Automatically handle timestamps
public $timestamps = true;
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
// Validation rules
protected $validationRules = [
'ip_address' => 'required|valid_ip|max_length[45]',
'attempts' => 'required|integer',
'last_attempt_at' => 'required|valid_date',
'blocked_until' => 'permit_empty|valid_date'
protected $casts = [
'attempts' => 'integer',
'last_attempt_at' => 'datetime',
'blocked_until' => 'datetime',
];
// Method to get IP attempt data by IP address
public function getAttemptByIp($ip)
/**
* Equivalent of CI getAttemptByIp()
*/
public static function getAttemptByIp(string $ip): ?self
{
return $this->where('ip_address', $ip)->first();
return static::query()
->where('ip_address', $ip)
->first();
}
// Method to update the IP attempt data
public function updateIpAttempt($ip, $data)
/**
* Equivalent of CI updateIpAttempt()
*/
public static function updateIpAttempt(string $ip, array $data): bool
{
return $this->where('ip_address', $ip)->set($data)->update();
return static::query()
->where('ip_address', $ip)
->update($data) >= 0;
}
// Method to insert new IP attempt data
public function insertIpAttempt($data)
/**
* Equivalent of CI insertIpAttempt()
* Returns inserted id.
*/
public static function insertIpAttempt(array $data): int
{
return $this->insert($data);
$row = static::query()->create($data);
return (int) $row->id;
}
}