closed) { throw new AlertClosed(); } if(is_null($userId)) { $userId = auth()->user()->id; } foreach($alert->crew as $crew) { if($crew->user->id == $userId) { if($crew->accepted != null) { throw new AlertResponseAlreadySet(); } else { $crew->accepted = $response; $crew->save(); } } } $user = User::find($userId); //Add to logs Logger::log( "Risposta ad allertamento: ".($response ? "presente" : "non presente"), $user, $fromTelegram ? $user : null, $fromTelegram ? "telegram" : "web" ); //Send message to the user via Telegram to notify the response $chatRows = TelegramBotLogins::join("users", "users.id", "=", "telegram_bot_logins.user") ->select("users.id", "chat_id", "users.available") ->where("users.id", $userId) ->whereNotNull("chat_id") ->get(); foreach ($chatRows as $chatRow) { //Get chat by id $chat = Telegraph::chat($chatRow["chat_id"]); $chat ->message( "La tua risposta all'allertamento รจ stata registrata.\n". "Sei ".($response ? "presente" : "assente").".\n". "Rimani in attesa di nuove istruzioni." ) ->send(); } } }