Open codebykyle opened 4 years ago
not work resource not have map function
To customise my name property I do this:
->optionsResolve(function ( $model ) {
return $model->relation1->relation2->map(function ($item) {
return collect([
'id' => $item->id,
'name' => $item->formatted_name,
]);
});
})
->withMeta(['titleKey' => 'name'])
I know it's pretty generic but I hope this helps someone in the same position I was.
Hello, Thanks for the package. This is very helpful. I had some trouble getting the title property to work. A few of the models I'm using need a particular title depending on the situation.
I just wanted to quickly share two of my solutions for this. You could also use an attribute on the model, per #11, but I wanted to use the Nova resource's title method.
This sets a temporary field on the model for
calculated_title
.Additionally, you can change the title key with
withMeta
, like:Is it possible to maybe expose the title key via a method to make this more formalized rather than going through
withMeta
?