Do you have code available to view?
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.
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)
}
Please or to participate in this conversation.