bernhardh / nova-dynamic-views

A nova package for dynamically overwrite the custom placeholders
16 stars 9 forks source link

Data for current model on detail page #4

Closed hmakein closed 3 years ago

hmakein commented 3 years ago

I'm using the customDetailToolbarComponents() method in a model, and I'm wondering if there's a way to pass in data about the current model that the detail page is displaying. My hope would be to at least get the model ID, then use that to pass the data I need as a second parameter on the addItem() method.

I tried getting the current model ID using request(), but that only provides information for the nova-vendor/nova-dynamic-views/{resource}/{method} route.

bernhardh commented 3 years ago

Please have a look at the new release v1.3.0 where I have added this feature and updated the the docs (https://github.com/bernhardh/nova-dynamic-views#access-resource-data).

To sum it up, now you have access to the id with request('id'). Then you can query for the model:

$this->model()->query()->where('id', request('id'))->first();

Is your problem solved with this?

hmakein commented 3 years ago

@bernhardh That worked perfectly. Thank you so much!