123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace App\Http\Controllers\Application;
- use Auth;
- use Illuminate\Http\Request;
- use App\Http\Controllers\Controller;
- class NotificationController extends Controller
- {
- public function __construct()
- {
- $this->middleware('admin');
- }
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function index()
- {
- $user = Auth::guard('admin')->user();
- return view('application.notifications.notifications');
- }
- public function partial()
- {
- $user = Auth::guard('admin')->user();
- $notifications = $user->notifications()->paginate(30);
- return view('application.notifications.notification_partial',compact('notifications'));
- }
- public function markAsRead(Request $request)
- {
- $user = Auth::user();
- $notification = $user->unreadNotifications()->where('id',$request->id)->first();
- if ($notification){
- $notification->markAsRead();
- }
- echo 'success';
- }
- public function markAllAsRead()
- {
- $user = Auth::user();
- $notifications = $user->unreadNotifications()->get();
- foreach ($notifications as $key => $notification) {
- $notification->markAsRead();
- }
- return redirect()->back();
- }
- }
|