<?php

declare(strict_types=1);

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

use Dingo\Api\Http\Response;
use Dingo\Api\Routing\Helpers;
use App\Http\Controllers\API\BaseController;
use Illuminate\Notifications\DatabaseNotificationCollection;

/**
 * Class ListAction
 *
 * @package App\Http\Controllers\API\V1\Pouzivatel\Notifications\Frontend
 */
final class ListAction extends BaseController
{
    use Helpers;

    /**
     * @return \Dingo\Api\Http\Response
     */
    public function __invoke(): Response
    {
        /**
         * @var DatabaseNotificationCollection $notifications
         */
        $notifications = $this->auth->user()->notifications()->limit(25)->get();

        return $this->response->array($notifications->toArray());
    }
}
