danzzz
Use Spatie Translate language in Tables / Forms
In case some needs it, solved it with this code:
Tables\Columns\TextColumn::make('parent.name')
->state(function($livewire, QuestionCategory $questionCategory) {
if(isset($questionCategory->parent->name))
return $questionCategory->parent->getTranslation('name',$livewire->activeLocale);
return '';
})
->label('Kategorie')
->searchable(),
4 replies
Adding an action button to the panel
may you can solve it with render hooks:
https://filamentphp.com/docs/3.x/support/render-hooks
It allows you to render Blade content at various points in the frameworks views.
4 replies
Display an image (ImageColumn) from local storage (not public accessible)
I ended up with this solution:
Forms\Components\ViewField::make('image')
->view('filament.tables.columns.custom-upload-preview'),
@php
use Intervention\Image\ImageManager;
use Intervention\Image\Drivers\Gd\Driver;
$manager = new ImageManager(new Driver());
$image = $manager->read(storage_path('app/').$getRecord()->file_name); // app/uploads/some.png
$image->scaleDown(200);
$base64 = base64_encode($image->encode());
@endphp
<img class="rounded-xl" src="{{ 'data:image/jpeg;base64,' . $base64 }}" alt="{{ $getRecord()->title }}">
3 replies
Pseude Toggle for activating an other field
Forms\Components\Toggle::make('with_uploads')
->live()
->afterStateHydrated(function (Announcement $announcement, Forms\Components\Toggle $component) {
if($announcement->uploads()->count()) {
$component->state(true);
} else {
$component->state(false);
}
}),
This works for me now. Thx.3 replies
How to conditionaly use headerActions for tables?
I solved it like described there:
https://filamentphp.com/docs/3.x/panels/resources/relation-managers#sharing-a-resources-form-and-table-with-a-relation-manager
and dont use a own class any more.
3 replies