Open hisyamali opened 1 month ago
//OrderObserver if ($order->status === Order::STATUS_PAYMENT_VERIFY || $order->status === Order::STATUS_RECEIVED) { $statusVerification = $order->status === Order::STATUS_PAYMENT_VERIFY ? 'Butuh Verifikasi' : Order::STATUS_PAYMENT_VERIFY; $statusReceived = $order->status === Order::STATUS_RECEIVED ? 'Butuh Penerusan Dana' : Order::STATUS_RECEIVED; if($statusVerification) { $message = "Pesanan #{$order->order_number} status: {$statusVerification} di Toko #{$order->merchant->name}"; } elseif($statusReceived) { $message = "Pesanan #{$order->order_number} status: {$statusReceived} di Toko #{$order->merchant->name}"; } Log::info('Sending notification', ['message' => $message]); // Kirim notifikasi Notification::route('telegram', env('TELEGRAM_CHAT_ID')) ->notify(new TelegramNotification($message)); } $merchants = Merchant::all(); // Ambil semua merchant // Cek status merchant if($merchants->contains('status', Merchant::STATUS_VERIFY)) { foreach ($merchants as $merchant) { $message = "Toko #{$merchant->name} butuh verifikasi"; Log::info('Sending notification', ['message' => $message]); // Kirim notifikasi Notification::route('telegram', env('TELEGRAM_CHAT_ID')) ->notify(new TelegramNotification($message)); } } //TelegramNotification public function via($notifiable) { return [TelegramChannel::class]; } public function toTelegram($notifiable) { $chat_id = env('TELEGRAM_CHAT_ID'); // Chat ID dari grup atau channel Telegram::sendMessage([ 'chat_id' => $chat_id, 'text' => $this->message ]); }