Notify Multiple users or group in application

Posted 2 months ago by yafeearun

Hi

i have tried to notify the group of people, but i can't made it, here i shared my code ,kindly help me to short out this

namespace App\Notifications;

use Illuminate\Bus\Queueable; use Illuminate\Notifications\Notification; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage;

use App\Models\Ticket;

class TicketAssignedNotification extends Notification { use Queueable;

protected $ticket;

/**
 * Create a new notification instance.
 *
 * @return void
 */
public function __construct(Ticket $ticket)
{
    $this->ticket = $ticket;
}

/**
 * Get the notification's delivery channels.
 *
 * @param  mixed  $notifiable
 * @return array
 */
public function via($notifiable)
{
    return ['database'];
}

/**
 * Get the mail representation of the notification.
 *
 * @param  mixed  $notifiable
 * @return \Illuminate\Notifications\Messages\MailMessage
 */
public function toMail($notifiable)
{

    return (new MailMessage)
                 ->line('The introduction to the notification.')
                 ->action('Notification Action', url('/'))
                 ->line('Thank you for using our application!');
}

/**
 * Get the msg representation of the notification.
 *
 * @param  mixed  $notifiable
 * @return string
 */
public function toDatabase($notifiable)
{
    // print_r($this->ticket);die();
    return [
        'module' => 'tickets',
        'module_id' => $this->ticket->id,
        'module_uuid' => $this->ticket->uuid,
        //'message' => "Hi there, a new ticket <a routerLink=\"/tickets/{$this->ticket->id}\">#{$this->ticket->reference_no}</a> has been created",
        'message' => "Hi there, a ticket #{$this->ticket->reference_no} has been assigned to you",
    ];
}

}

it stores only one user (the assigned one ) but i have to notify the entire team

and my table structure

id char(36) COLLATE utf8mb4_unicode_ci NOT NULL, type varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, notifiable_type varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, notifiable_id bigint(20) UNSIGNED NOT NULL, data text COLLATE utf8mb4_unicode_ci NOT NULL, read_at timestamp NULL DEFAULT NULL, created_at timestamp NULL DEFAULT NULL, updated_at timestamp NULL DEFAULT NULL

Please sign in or create an account to participate in this conversation.