0
votes

I have an application that sends notifications to admins on some user's actions. some admins should notify by SMS and others just via database. what is the best way to do this? use two notifications or just one? I didn't found any way to change notifiables by their notify method in a notification.

Is there any suggestion?

1

1 Answers

0
votes

it can work with If Statement

class yourNotifName extends Notification
{
    use Queueable;
    private $role;
    private $notif;

    public function __construct(User $user)
    {
        $this->role= $user->role;
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        if($this->role == "admins") {
            $this->notif = ['sms'];
        } else {
           $this->notif = ['database'];
        }
        return $this->notif;
    }
}