ldc-gen-game-web/app/Models/BannedIp.php
2025-08-14 14:12:13 +00:00

72 lines
1.5 KiB
PHP

<?php
namespace App\Models;
use App\Casts\Ip;
use App\Traits\Models\ActivityLog;
use App\Traits\Models\IsCachedAsCollection;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
* BannedIp.
*
* @property integer $ip IP.
*
* @property-read \App\Models\ActivityLog $activityLogs Activities logs One-to-many relationship.
*/
class BannedIp extends Model
{
use ActivityLog;
use IsCachedAsCollection;
use HasFactory;
/**
* Indicates if the model should be timestamped.
*
* @var boolean
*/
public $timestamps = false;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = ['ip'];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'ip' => Ip::class
];
// * EVENTS
/**
* Perform any actions required after the model boots.
*
* @return void
*/
protected static function booted()
{
static::created(fn () => self::removeCached());
static::updated(fn () => self::removeCached());
static::deleted(fn () => self::removeCached());
}
// * RELATIONS
/**
* Activities logs One-to-many relationship.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function activityLogs(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(ActivityLog::class);
}
}