<?php

namespace Modules\Notification\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Services\Response\ResponseService;
use Illuminate\Http\Request;
use Modules\Notification\Resources\Api\NotificationResource;
use Modules\Notification\Services\NotificationService;
use Modules\User\Services\UserService;


class NotificationController extends Controller
{

    public function __construct(
        private NotificationService $notificationService,
        private UserService $userService,
    ) {
    }
    /**
     * Get Packages.
     *
     * @param Request $request
     * @return void
     */
    public function index(Request $request): void
    {
        $user = auth()->user();
        $credentials['api'] = true;
        $this->userService->update(['unread_notification' => 0], $user->id);
        $query = $this->notificationService->get($credentials);

        $response = [
            "query" => $query,
            "request" => $request,
            "resourceClass" => NotificationResource::class,
            "returnName" => "notifications"
        ];
        ResponseService::fetchPainateDate($response);
    }



}
