Files
2025-11-30 11:57:22 +01:00

114 lines
3.4 KiB
PHP

<?php
namespace Paymenter\Extensions\Others\ContactPage\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
class AbuseReport extends Model
{
protected $table = 'ext_abuse_reports';
protected $fillable = [
'reporter_name',
'reporter_email',
'abuse_type',
'reported_url',
'reported_user',
'description',
'evidence',
'status',
'admin_notes',
'ip_address',
'user_agent',
'investigated_at',
'resolved_at',
];
protected $casts = [
'investigated_at' => 'datetime',
'resolved_at' => 'datetime',
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
public static function getAbuseTypes(): array
{
return [
'phishing' => 'Anti-Phishing Act of 2005 Violation/Content Takedown Request (Phishing Scam)',
'hacking' => 'Computer Fraud and Abuse Act of 1986 (CFAA) Violation/Hacking Attempt Report (Request for Investigation)',
'spam' => 'Controlling the Assault of NonSolicited Pornography and Marketing Act of 2003 (CAN-SPAM) Violation (Email Spam)',
'dmca' => 'Digital Millennium Copyright Act (DMCA) Infringement/Copyright Takedown Request (Internet Piracy)',
'illegal_content' => 'Illegal Content Takedown Request (In Violation of Ohio Revised Code (ORC), or Federal Law within United States) ',
'network' => 'Network Abuse Report (DDoS, Port Scanning, etc. Computer Fraud and Abuse Act of 1986 Violation (CFAA))',
'other' => 'Other (Please Specify in Description, e.g., Fraud, Identity Theft, etc.)',
];
}
public function scopePending(Builder $query): Builder
{
return $query->where('status', 'pending');
}
public function scopeInvestigating(Builder $query): Builder
{
return $query->where('status', 'investigating');
}
public function scopeResolved(Builder $query): Builder
{
return $query->where('status', 'resolved');
}
public function markAsInvestigating(): void
{
$this->update([
'status' => 'investigating',
'investigated_at' => now(),
]);
}
public function markAsResolved(): void
{
$this->update([
'status' => 'resolved',
'resolved_at' => now(),
]);
}
public function dismiss(): void
{
$this->update([
'status' => 'dismissed',
'resolved_at' => now(),
]);
}
public function getStatusColorAttribute(): string
{
return match ($this->status) {
'pending' => 'danger',
'investigating' => 'warning',
'resolved' => 'success',
'dismissed' => 'gray',
default => 'gray',
};
}
public function getFormattedStatusAttribute(): string
{
return match ($this->status) {
'pending' => 'Pending',
'investigating' => 'Investigating',
'resolved' => 'Resolved',
'dismissed' => 'Dismissed',
default => ucfirst($this->status),
};
}
public function getFormattedAbuseTypeAttribute(): string
{
return self::getAbuseTypes()[$this->abuse_type] ?? ucfirst($this->abuse_type);
}
}