Hello Friends,
I am creating a hook that should retrieve information from the 'message' column of the 'tblemails' table.
In the 'message' column, there is a large amount of information that I am not interested in, so I created a filter (with the help of ChatGPT). It works, but interestingly, it doesn't filter out some things.
Is there a more efficient way to create a filter?
Here is the code I am using:
// msg content
$email_query = Capsule::table('tblemails')
->where('userid', $userid)
->where('subject', 'like', '%' . $invoice_id . '%')
->orderBy('id', 'desc')
->value('message');
// filter
if (preg_match('/value="([^"]*)"/i', $email_query, $matches)) {
// $matches[1] conterá o conteúdo dentro das aspas duplas após "data-pix="
$msgtest = htmlspecialchars($matches[1], ENT_QUOTES, 'UTF-8');
echo $msgtest;
} else {
// msg error
}