ctrlpanel/app/Http/Controllers/NotificationController.php

35 lines
880 B
PHP
Raw Normal View History

2021-06-05 09:26:32 +00:00
<?php
namespace App\Http\Controllers;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Notifications\Notification;
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
]);
}
}