Add all files
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace Paymenter\Extensions\Others\ComplianceTools\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AccountDeletionRequest extends Model
|
||||
{
|
||||
public const STATUS_PENDING = 'pending';
|
||||
public const STATUS_APPROVED = 'approved';
|
||||
public const STATUS_DENIED = 'denied';
|
||||
public const STATUS_COMPLETED = 'completed';
|
||||
|
||||
protected $table = 'ext_compliance_deletion_requests';
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'status',
|
||||
'reason',
|
||||
'admin_notes',
|
||||
'processed_by',
|
||||
'processed_at',
|
||||
'snapshot',
|
||||
'metadata',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'processed_at' => 'datetime',
|
||||
'snapshot' => 'array',
|
||||
'metadata' => 'array',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function processor()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'processed_by');
|
||||
}
|
||||
|
||||
public function isPending(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn () => $this->status === self::STATUS_PENDING,
|
||||
);
|
||||
}
|
||||
|
||||
public function isApproved(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn () => $this->status === self::STATUS_APPROVED,
|
||||
);
|
||||
}
|
||||
|
||||
public function scopePending($query)
|
||||
{
|
||||
return $query->where('status', self::STATUS_PENDING);
|
||||
}
|
||||
}
|
||||
35
extensions/Others/ComplianceTools/Models/AuditLog.php
Normal file
35
extensions/Others/ComplianceTools/Models/AuditLog.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Paymenter\Extensions\Others\ComplianceTools\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AuditLog extends Model
|
||||
{
|
||||
protected $table = 'ext_compliance_audit_logs';
|
||||
|
||||
protected $fillable = [
|
||||
'category',
|
||||
'event',
|
||||
'subject_user_id',
|
||||
'actor_type',
|
||||
'actor_id',
|
||||
'ip_address',
|
||||
'context',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'context' => 'array',
|
||||
];
|
||||
|
||||
public function subject()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'subject_user_id');
|
||||
}
|
||||
|
||||
public function actor()
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
}
|
||||
61
extensions/Others/ComplianceTools/Models/SupportPin.php
Normal file
61
extensions/Others/ComplianceTools/Models/SupportPin.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace Paymenter\Extensions\Others\ComplianceTools\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class SupportPin extends Model
|
||||
{
|
||||
protected $table = 'ext_compliance_support_pins';
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'pin_hash',
|
||||
'pin_lookup',
|
||||
'expires_at',
|
||||
'revoked_at',
|
||||
'last_validated_at',
|
||||
'created_ip',
|
||||
'created_user_agent',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'expires_at' => 'datetime',
|
||||
'revoked_at' => 'datetime',
|
||||
'last_validated_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
'is_active',
|
||||
'is_expired',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
protected function isActive(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn () => !$this->is_expired && is_null($this->revoked_at),
|
||||
);
|
||||
}
|
||||
|
||||
protected function isExpired(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn () => $this->expires_at instanceof Carbon && $this->expires_at->isPast(),
|
||||
);
|
||||
}
|
||||
|
||||
public function scopeActive($query)
|
||||
{
|
||||
return $query
|
||||
->whereNull('revoked_at')
|
||||
->where('expires_at', '>', now());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user