search

Home  >  Q&A  >  body text

Display images from related search resources in Laravel Nova

I create fields using relationships

BelongsTo::make

and want to add a search title image, the link to the image is stored as a url in the resource field

I tried making an img tag but the title escaped the html code

public function title()
{
    return "$this->name <img src='/open_emoji/lite_colored/$this->name.png'>";
}

https://nova.laravel.com/docs/4.0/resources/relationships.html#searchable-relations The documentation shows a picture to show that this is possible and that's it!

There is also a specific avatar field, but it's also poorly documented, and there's no explanation of how relationships are handled.

Can someone explain how to do this? I am using nova 4

P粉986937457P粉986937457227 days ago380

reply all(1)I'll reply

  • P粉936568533

    P粉9365685332024-04-01 16:39:08

    So we need to use

    in the sub-resource avatar field

    Documentation: If a resource contains an avatar field, this field will appear next to the resource title when the resource appears in search results. https://nova.laravel.com/docs/4.0/ resources/fields.html#avatar-field

    reply
    0
  • Cancelreply