TransWikia.com

send multiple notification with one notification class in laravel

Stack Overflow Asked by Farshad on January 25, 2021

hi i have a laravel notification class that i use telegram channel to send notifications to telegram . now what i want is to send like 3 notifications with one class so here is my code :

 $task = Task::with('users')->findorfail($request->get('task_id'));
                foreach ($task->users as $item) {
                    $task->notify(new TaskAssign($item,$task));
                }
        return 'done';

and here in my task assign i want to use this methods :

public function via($notifiable)
    {
        return [TelegramChannel::class];
    }
    public function toTelegram($notifiable)
    {
        return TelegramLocation::create()
             ->to('108070198')

            ->latitude('40.6892494')
            ->longitude('-74.0466891');

//        return
//            TelegramMessage::create()
//            // Optional recipient user id.
//            ->to('')
//            // Markdown supported.
//            ->document('https://file-examples.com/wp-content/uploads/2017/10/file-sample_150kB.pdf', 'sample.pdf')
//
//            // (Optional) Blade template for the content.
//            // ->view('notification', ['url' => $url])
//
//            // (Optional) Inline Buttons
//          
    }

now i know that its possible to make different classes for each one but i want to send message file and location all together in one notification class . how can that be done . thanks

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP