「分享」自己写的标记单条消息为已读
routes/api.php
// 标记单条消息通知为已读
$api->put('user/read/notifications/{notification}', 'NotificationsController@readSingle')
->name('api.user.notifications.readSingle');
app/Http/Controllers/Api/NotificationsController.php
//标记单个消息通知为已读
public function readSingle(DatabaseNotification $notification)
{
$this->user()->decrement('notification_count');
$notification->markAsRead();
return $this->response->noContent();
}
测试:
数据库notifications
表:
推荐文章: