I am looking at filtering my database notifications with an attribute in my data column. We're talking about the default notifications table created by Laravel.
I was (pleasantly) surprised to see that the following query actually works! :
I'm wondering if this query is efficient if my data column is text? Should I go about making it json?
But before coming up with above solution, my attempt was this -
$notifications = auth()->user()->unreadNotifications()->get();
// Only pick the notifications that belong to current tenant
$notifications->filter(function($value) use($request) {
return $value->data['tenant_id'] = $request->tenant->id;
});
This code threw error -
Indirect modification of overloaded property Illuminate\Notifications\DatabaseNotification::$data has no effect