add projet
This commit is contained in:
Executable
+52
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\BaseModel;
|
||||
|
||||
class IpAttempt extends BaseModel
|
||||
{
|
||||
protected $table = 'ip_attempts';
|
||||
protected $primaryKey = 'id';
|
||||
protected $fillable = [
|
||||
'ip_address',
|
||||
'attempts',
|
||||
'last_attempt_at',
|
||||
'blocked_until',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'school_year',
|
||||
'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'
|
||||
];
|
||||
|
||||
// Method to get IP attempt data by IP address
|
||||
public function getAttemptByIp($ip)
|
||||
{
|
||||
return $this->where('ip_address', $ip)->first();
|
||||
}
|
||||
|
||||
// Method to update the IP attempt data
|
||||
public function updateIpAttempt($ip, $data)
|
||||
{
|
||||
return $this->where('ip_address', $ip)->set($data)->update();
|
||||
}
|
||||
|
||||
// Method to insert new IP attempt data
|
||||
public function insertIpAttempt($data)
|
||||
{
|
||||
return $this->insert($data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user