I'm stuck with putting a html output in Laravel 7 & nova 3.8
according to: https://nova.laravel.com/docs/3.0/search/global-search.html#title-subtitle-attributes
i try to make a function that put a html image in front of some resource on index pages:
public function title()
{
return "<img width='20px' height='10px' src='./flags/".$this->country.".png' >";
}
I read that laravel 7 use {!! !!} ( https://laravel.com/docs/7.x/blade#displaying-data ) But if i use it in resource file in app/nova/some-resource.php php gives error.
How to easy put a image based on country field in resource title ?
-- update 23.08.2020
I tried to create a Text field in my resource as it can have ->asHtml() and i have a nice flag image on index and detail view
public function fields(Request $request)
{
return [
(...)
Text::make('Country Flag',
function () {
return "<img width='20px' height='10px' src='http://fishmarket.nowakadmin.com/flags/".$this->country.".png' >";
})->asHtml(),
(...)
]};
and in title i changed to:
public function title()
{
return $this->country_flag.' '.$this->name;
}
Result is that title looks like
''' '.$this->name // it looks like $this->country_flag = '';