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

digitalagua's avatar

Laravel Nova Custom Tool pass data from Tool.php or ToolServiceProvider.php to Tool.vue.

Hi.

I am looking for some help. I am building a Laravel Nova Custom Tool and I want to pass data from Tool.php or ToolServiceProvider.php to Tool.vue.

Using Fields and Resource Tools I can use ->withMeta() but I am not seeing any thing like that for Tools. I could load the data through an API call, but I'd like to have the data available on page load.

It seems like I am just missing something obvious.

0 likes
8 replies
digitalagua's avatar

@devingray_ No. I have a bunch of code that doesn't even come close to working and call methods that don't exist. It is more of a how does Nova do it question than why doesn't this work.

devingray_'s avatar
Level 8

Ok cool.

So first up, what you need to do is create the tool.

php artisan nova:tool name/tool

This will create the tool you need.

The tool will contain

resources/ => js files
Tool.php => Tool Class
ToolServiceProvider.php => ServiceProvider to register into the container

in the ToolServiceProvider.php

You can add use the Nova provideToScript() method


public function boot()
{
       Nova::serving(function (ServingNova $event) {
            Nova::provideToScript([
                'tool' => [
                    'something' => 'something',
                    'something_else' => 'something_else',
                ],
            ]);
        });
}

Now you will have this available in the Vue files

mounted() {
 console.log(Nova.config.tool.something)
}
4 likes
digitalagua's avatar

@devingray_ This is exactly what I need, thanks! Do you know if there is any good documentation on the Nova javascript object?

digitalagua's avatar

I have read through that site a few times now and completely blew past that. Thanks again!

Please or to participate in this conversation.