简体   繁体   English

laravel nova中关系搜索资源如何显示图片

[英]How to show image in relation search resource in laravel nova

i make field with relation我用关系创建字段

BelongsTo::make

and want add for search title image, the link to the image is stored in the resource field as url并希望添加搜索标题图片,图片链接存储在资源字段中,为 url

I tried to make an img tag, but the title escapes the html code我试图制作一个 img 标签,但标题转义了 html 代码

    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 that this is possible and that's it! https://nova.laravel.com/docs/4.0/resources/relationships.html#searchable-relations文档显示了一张图片,这是可能的,仅此而已!

there is also a certain avatar field, but which is just as terribly documented and does not explain how to work with relationships.还有一个特定的头像字段,但它的记录非常糟糕,并且没有解释如何处理关系。

Can someone please explain how to do this?有人可以解释如何做到这一点吗? i am use nova 4我在用 nova 4

So we need use in child resource avatar field所以我们需要在子资源头像字段中使用

Docs: If a resource contains an Avatar field, that field will be displayed next to the resource's title when the resource is displayed in search results.文档:如果资源包含 Avatar 字段,当资源显示在搜索结果中时,该字段将显示在资源标题旁边。 https://nova.laravel.com/docs/4.0/resources/fields.html#avatar-field https://nova.laravel.com/docs/4.0/resources/fields.html#avatar-field

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM