I have a table setup:
CREATE TABLE `notifications` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`user_id` int(11) DEFAULT NULL,
`dismissed` int(1) DEFAULT NULL,
`name` text COLLATE utf8_unicode_ci NOT NULL,
`importance` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Then I call Notifications::all(); from my controller to get all notifications. But this isn't showing to every user, the user_id column is only used to update the post that a user a read the notification.
I do have a loop too.
@foreach ($notifications as $notification)
<div class="notifications">
@if ($notification->importance == 'High' && $notification->user_id == Auth::id() && $notification->dismissed != 1)
<div class="notify danger">
<button type="button" class="close del-banner-btn" data-notify-id="High" name="close" data-banner-id="1" data-user-id="{!! Auth::id() !!}">×</button>
{!! $notification->name !!}
</div>
@endif
</div>
@endforeach
But ideally every notification needs to be notified to all users, then not displayed when the user clicks a X and the table is updated.
Not sure I've gone about this the right way so asking for some help advice on this...