ctrlpanel/app/Http/Controllers/NotificationController.php

38 lines
940 B
PHP
Raw Normal View History

2021-06-05 09:26:32 +00:00
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Auth;
class NotificationController extends Controller
{
2021-06-06 18:17:52 +00:00
/** Display a listing of the resource. */
2021-06-06 21:26:36 +00:00
public function index()
2021-06-05 09:26:32 +00:00
{
$notifications = Auth::user()->notifications()->paginate();
return view('notifications.index')->with([
'notifications' => $notifications
]);
}
2021-06-06 18:17:52 +00:00
/** Display the specified resource. */
2021-06-06 21:26:36 +00:00
public function show(string $id)
2021-06-05 09:26:32 +00:00
{
$notification = Auth::user()->notifications()->findOrFail($id);
$notification->markAsRead();
return view('notifications.show')->with([
'notification' => $notification
]);
}
2022-06-02 06:44:54 +00:00
public function readAll(){
$notifications = Auth::user()->notifications()->get();
foreach($notifications as $notification){
$notification->markAsRead();
}
2022-06-02 06:50:44 +00:00
return redirect()->back();
2022-06-02 06:44:54 +00:00
}
2021-06-05 09:26:32 +00:00
}