<?php

namespace App\Http\Controllers\API\V1\Pouzivatel\Notifications\Frontend;

use App\Http\Controllers\API\BaseController;
use App\Notifications\Push\MAAISEKUserNotificationsCountPushNotification;
use Dingo\Api\Http\Response;

/**
 *
 */
final class MarkAllAsReadAction extends BaseController
{
    /**
     * @return Response
     */
    public function __invoke(): Response
    {
        $pouzivatel = $this->auth->user();
        $pouzivatel->unreadNotifications()->each(function ($notification) {
            $notification->markAsRead();
        });
        $pouzivatel->notify(new MAAISEKUserNotificationsCountPushNotification());

        return $this->response->accepted();
    }
}
