mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-21 02:39:10 -04:00
update notification
This commit is contained in:
27
app/Http/Controllers/NotificationController.php
Normal file
27
app/Http/Controllers/NotificationController.php
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -272,4 +272,9 @@ class UserController extends Controller
|
||||
{
|
||||
return view('admin.user.course',['courses' => User::find($id)->courses]);
|
||||
}
|
||||
|
||||
public function userNotification()
|
||||
{
|
||||
return view('admin.user.profil.notifications',['notifications' => \Auth::user()->notifications]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user