bernhardh
1 year ago
895
1
Nova

Access model data in a nova card

Posted 1 year ago by bernhardh

I am writing a custom nova card to display some basic infos of a ressource on detail view (for example created_at, updated_at, deeplink to the frontend of this ressource, etc.). How can I access model data for this?

I know, i could access "resource" property in vue (resource.fields), but the problem is, that I would have to go through all the fields to get the right one, since its an array, not a object.

Otherwise I would have to do something like so:

function getFieldValue(fieldName) {
    for(fieldIndex in resource.fields) {
        let field = resource.fields[fieldIndex];
        if(field.name == fieldName) return field.value;
    }
}

But this will not work, if I use Panels or if the tab-package.

Isn't there an easy way to just access the model-data in the Card-Class in php and then pass it to Vue with withMeta?

Please sign in or create an account to participate in this conversation.