<?php

namespace App\Http\Controllers\Frontend;

use App\Http\Controllers\Controller;
use App\Services\NotificationService;

class NotificationsController extends Controller
{
    protected $data = [];
    protected $notificationService;

    public function __construct(NotificationService $notificationService)
    {
        $this->data['title'] = 'Notifications';

        $this->notificationService = $notificationService;
    }

    public function index()
    {
        $this->data['notifications'] = $this->notificationService->getNotifications();

        return view('theme::pages.account.notifications', $this->data);
    }

    public function markAsRead($id)
    {
        $this->notificationService->markAsRead($id);

        return redirect()->back();
    }

    public function markAllAsRead()
    {
        $this->notificationService->markAllAsRead();

        return redirect()->back();
    }

    public function deleteAll()
    {
        $this->notificationService->deleteAllNotifications();

        return redirect()->back();
    }
}
