NotificationController.php 880 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Contracts\View\Factory;
  4. use Illuminate\Contracts\View\View;
  5. use Illuminate\Http\Request;
  6. use Illuminate\Http\Response;
  7. use Illuminate\Notifications\Notification;
  8. use Illuminate\Support\Facades\Auth;
  9. class NotificationController extends Controller
  10. {
  11. /** Display a listing of the resource. */
  12. public function index()
  13. {
  14. $notifications = Auth::user()->notifications()->paginate();
  15. return view('notifications.index')->with([
  16. 'notifications' => $notifications
  17. ]);
  18. }
  19. /** Display the specified resource. */
  20. public function show(string $id)
  21. {
  22. $notification = Auth::user()->notifications()->findOrFail($id);
  23. $notification->markAsRead();
  24. return view('notifications.show')->with([
  25. 'notification' => $notification
  26. ]);
  27. }
  28. }