Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

petergartin's avatar

Nova Resource Actions method called an unecessary amount of times on Index load

Hello,

I am running into many repeated queries on my resource index page. These queries are coming from Actions fields() method which I have registered with my resource like so:

public function actions(Request $request)
    {
        return [
            new ApplyTemplate
        ];
    }

On loading my resource index page, the resource actions method is run many times for a request with the url: /nova-api/{resourceName} And once for the /nova-api/{resourceName}/actions

It seems like those actions() calls are unnecessary for those many /nova-api/{resourceName} requests. Is that the expected behavior? I have been using a hacky fix by returning an empty array for the actions() for resource index requests:

public function actions(Request $request)
    {
        if ($request instanceof ResourceIndexRequest) {
            return [];
        }

        return [
            new ApplyTemplate,
        ];
    }

And the actions appear and function as normal. But now I feel I need to add this work around to all of my resources which have queries as a part of their actions' fields() method.

Does anyone have any incite into this issue?

0 likes
0 replies

Please or to participate in this conversation.