<?php
function trigger_webhook($event,$payload)
{
    $db = \App\Core\Database::getInstance();
    $hooks = $db->prepare("SELECT url FROM webhooks WHERE event=?");
    $hooks->execute([$event]);

    foreach($hooks->fetchAll() as $h){
        file_get_contents($h['url']."?data=".urlencode(json_encode($payload)));
    }
}
