It seems like you're asking how to render HTML content in a Filament admin panel, specifically using the html_entity_decode function in a Blade view. Filament uses Blade components extensively, so you can achieve this by creating a custom column or field that renders HTML content safely.
Here's a basic example of how you might set this up in a Filament resource:
-
Create a Custom Column for Displaying HTML Content
You can create a custom column in your Filament resource that uses Blade to render the HTML content. Here's how you might define this column in your resource's
getTableColumns()method:
use Filament\Tables;
use Filament\Tables\Columns\TextColumn;
class OrderResource extends Tables\Table
{
protected function getTableColumns(): array
{
return [
TextColumn::make('title')
->html()
->formatStateUsing(function ($state) {
return html_entity_decode($state);
}),
];
}
}
In this example, the TextColumn is used with the html() method to indicate that the column may contain HTML. The formatStateUsing method is used to decode the HTML entities.
-
Ensure Safe Content Rendering
When rendering HTML content directly from the database, it's crucial to ensure that this content is safe to prevent XSS (Cross-Site Scripting) attacks. Make sure that any user-provided content that might be rendered as HTML is properly sanitized before saving it to the database.
-
Using the Custom Column in Filament
Once you have defined your custom column, it will automatically be used in the Filament admin panel for the
Orderresource. You don't need to make any additional changes to view the decoded HTML in the admin panel.
This approach keeps your application secure while allowing certain HTML content to be rendered in the Filament admin panel. Always be cautious with HTML content and ensure it's from a trusted source or sanitized appropriately.