36 lines
888 B
PHP
36 lines
888 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Core\Security;
|
|
|
|
/**
|
|
* MessageLog Model
|
|
* Records every message sent or received with full payload encryption.
|
|
*/
|
|
class MessageLog extends BaseModel
|
|
{
|
|
protected static string $table = 'messages_log';
|
|
|
|
/**
|
|
* Securely log a new message
|
|
*/
|
|
public static function logMessage(array $data)
|
|
{
|
|
if (!empty($data['contact_phone'])) {
|
|
$data['contact_phone_hash'] = Security::blindIndex($data['contact_phone']);
|
|
$data['contact_phone'] = Security::encrypt($data['contact_phone']);
|
|
}
|
|
|
|
if (!empty($data['message_body'])) {
|
|
$data['message_body'] = Security::encrypt($data['message_body']);
|
|
}
|
|
|
|
if (!empty($data['media_url'])) {
|
|
$data['media_url'] = Security::encrypt($data['media_url']);
|
|
}
|
|
|
|
return self::create($data);
|
|
}
|
|
}
|