select("users.id", "chat_id", "users.available")
->where("users.availability_manual_mode", true)
->whereNotNull("chat_id")
->get();
foreach ($users as $user) {
//Get chat by id
$chat = Telegraph::chat($user["chat_id"]);
$state = $user["available"] ? "disponibile 🟢" : "non disponibile 🔴";
$chat
->message(
"⚠️ Attenzione! La tua disponibilità non segue la programmazione oraria." .
"\nAttualmente sei $state" .
"\nSe vuoi mantenere questa impostazione,\nignora questo messaggio."
)
->keyboard(Keyboard::make()->buttons([
Button::make("🔧 Ripristina programmazione 🔧")->action('manual_mode_off')->param("user_id", $user["id"]),
Button::make("🗑 Elimina notifica 🗑")->action('delete_notification')
]))
->send();
}
}
public function failed($exception = null)
{
if (app()->bound('sentry')) {
app('sentry')->captureException($exception);
}
}
}