Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call to a member function toNotGiven() on null #198

Open
hisyamali opened this issue Jul 22, 2024 · 0 comments
Open

Call to a member function toNotGiven() on null #198

hisyamali opened this issue Jul 22, 2024 · 0 comments

Comments

@hisyamali
Copy link

hisyamali commented Jul 22, 2024

    //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
    ]);
 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant