You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for the package - this is the exact functionality I was looking to implement.
I have created a base notification class that I plan to use for all notifications on a given Class. The base notification implements an interface which declares getSubscriptionModel().
The goal is to be able to unsubscribe from notifications for any particular Model of that class; however, if it's setup like this, it breaks attempts to unsubscribe from the Notification class itself.
ex:
interface CanUnsubscribe
{
public function getSubscriptionModel($notifiable) : \Illuminate\Database\Eloquent\Model;
}
abstract class RequestNotification extends Notification implements ShouldQueue, CanUnsubscribe
{
use Queueable;
public Request $request;
public bool $ignoreSubscriptions;
public function __construct(Request $request, $ignore = false)
{
$this->request = $request;
$this->ignoreSubscriptions = $ignore;
}
public function getSubscriptionModel($notifiable): \Illuminate\Database\Eloquent\Model
{
return $this->request;
}
}
The user will still receive the notification unless you specify the model in the unsubscribe call.
I would expect that if you've unsubscribed from a notification, you should not receive that notification, regardless of it's implementation of the getSubscriptionModel() function or not.
The text was updated successfully, but these errors were encountered:
Hi @michaelhume ! I encountered a similar issue in my app and discovered that you can bypass this behavior by checking to see if the $notifiable passed into the getSubscriptionModel() method has a model-specific NotificationSubscription for the Notification.
For example:
public function getSubscriptionModel($notifiable)
{
return $notifiable->notificationSubscriptions()->model($this->yourModel)->doesntExist()
? null
: $this->yourModel;
}
Whenever getSubscriptionModel() returns null, the subscription logic treats it as though there should be no subscription-model requirement.
Hello,
Thanks for the package - this is the exact functionality I was looking to implement.
I have created a base notification class that I plan to use for all notifications on a given Class. The base notification implements an interface which declares getSubscriptionModel().
The goal is to be able to unsubscribe from notifications for any particular Model of that class; however, if it's setup like this, it breaks attempts to unsubscribe from the Notification class itself.
ex:
Then if you try
$user->unsubscribe(NotifyRequestStateChanged)
The user will still receive the notification unless you specify the model in the unsubscribe call.
I would expect that if you've unsubscribed from a notification, you should not receive that notification, regardless of it's implementation of the getSubscriptionModel() function or not.
The text was updated successfully, but these errors were encountered: