update notification

This commit is contained in:
Mathieu Lagace
2020-07-27 16:41:28 -04:00
parent c16d1e7e95
commit 2d64d6d422
28 changed files with 1167 additions and 47 deletions

View File

@@ -0,0 +1,27 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Notifications\DatabaseNotification;
class NotificationController extends Controller
{
public function markAsRead($id)
{
$n = DatabaseNotification::find($id);
$n->read_at = date('Y-m-d h:i:s');
$n->save();
}
public function markAllAsRead()
{
$notifications = \Auth::user()->unreadNotifications;
foreach ($notifications as $n)
{
$n->read_at = date('Y-m-d h:i:s');
$n->save();
}
return $notifications;
}
}