Akimbo
Akimbo
FFilament
Created by Akimbo on 4/10/2025 in #❓┊help
Filament V3 not working with s3 and image column
I have made an image column that I am uploading to s3. The upload works when I am initially creating a form, I can see the image in s3. But when I go to save the resource, the column fails with validation "The school Logo field must be a file of type: image/*". This is despite successfully saving it to s3. I am uploading a png. Here is the form and table column.
Tables\Columns\ImageColumn::make('path')
->disk('s3')
->width(100)
->height(100)
->label('Logo')
->visibility('public')
Tables\Columns\ImageColumn::make('path')
->disk('s3')
->width(100)
->height(100)
->label('Logo')
->visibility('public')
Forms\Components\FileUpload::make('path')
->label("School Logo")
->disk('s3')
->visibility('public')
->image()
Forms\Components\FileUpload::make('path')
->label("School Logo")
->disk('s3')
->visibility('public')
->image()
11 replies
FFilament
Created by Akimbo on 3/18/2025 in #❓┊help
In resources, where do I put database queries that I only want to run once?
The ->hidden() method runs 5 times per row in my app, and that seems to be the default with filament. I really need the result of it to be based on a user permission, but that would mean fetching that permission lots of times when I don't need it. Is there a place in a resource similar to mount where I can load something once and access it?
10 replies
FFilament
Created by Akimbo on 3/6/2025 in #❓┊help
Can't add scripts to admin panel service provider
I tried adding the scripts as indicated here, but it doesn't appear on any part of the filament admin app. For context, I am on a Laravel 11 app that uses Volt. But the file is still just a JS file sitting in that resources folder. https://filamentphp.com/docs/3.x/support/assets#registering-javascript-files
class AdminPanelProvider extends PanelProvider
{
public function boot(): void
{
FilamentAsset::register([
Js::make('app', __DIR__ . '/../../../resources/js/app.js'),
]);
}
class AdminPanelProvider extends PanelProvider
{
public function boot(): void
{
FilamentAsset::register([
Js::make('app', __DIR__ . '/../../../resources/js/app.js'),
]);
}
31 replies
FFilament
Created by Akimbo on 3/4/2025 in #❓┊help
How do you call methods with a Custom Column?
I have been able to make a custom column, but I have been trying to figure out how to actually call methods. If I try to use it like a volt component, it is not able to to see volt functions Clicking here will give "toggleLiveStatus undefined"
<?php
use Livewire\Volt\Component;
use App\Models\Event;
$isDisabled = $isDisabled();
$state = $getState();
$id = $getRecord()->id;
new class extends Component {
public function toggleLiveStatus()
{
$record = Event::find($id);
$record->is_live = !$record->is_live;
$record->save();
}
};
?>

<div>
<x-filament::button
wire:click.prevent="toggleLiveStatus({{ $getRecord()->id }})"
:color="$getRecord()->is_live ? 'success' : 'gray'"
>
{{ $getRecord()->is_live ? 'Live' : 'Offline' }}
</x-filament::button>
</div>
<?php
use Livewire\Volt\Component;
use App\Models\Event;
$isDisabled = $isDisabled();
$state = $getState();
$id = $getRecord()->id;
new class extends Component {
public function toggleLiveStatus()
{
$record = Event::find($id);
$record->is_live = !$record->is_live;
$record->save();
}
};
?>

<div>
<x-filament::button
wire:click.prevent="toggleLiveStatus({{ $getRecord()->id }})"
:color="$getRecord()->is_live ? 'success' : 'gray'"
>
{{ $getRecord()->is_live ? 'Live' : 'Offline' }}
</x-filament::button>
</div>
Methods defined in the custom class itself will also don't register.
class EventLiveSwitcher extends Column
{
protected string $view = 'tables.columns.event-live-switcher';

public function toggleLiveStatus($eventId)
{
$event = Event::findOrFail($eventId);
$event->update([
'live' => !$event->live,
]);
$event->save();
}
}
class EventLiveSwitcher extends Column
{
protected string $view = 'tables.columns.event-live-switcher';

public function toggleLiveStatus($eventId)
{
$event = Event::findOrFail($eventId);
$event->update([
'live' => !$event->live,
]);
$event->save();
}
}
I really am just trying to make a callback for clicking on the columns button.
8 replies
FFilament
Created by Akimbo on 3/3/2025 in #❓┊help
No way to add sideeffects to ToggleColumn?
I am making an admin panel to interact with another API. When the user toggles a ToggleColumn switch, I want to conditionally allow the state change depending on the API. Unfortunately I can't get any kind of conditional state change on ToggleColumn. I have tried updating the event after state is updated.
Tables\Columns\ToggleColumn::make('live')
->sortable()
->afterStateUpdated(function (Event $event) {
if ($event->live == '1') {
$event->update(['live' => '0']);
$event->save();
}
}),
Tables\Columns\ToggleColumn::make('live')
->sortable()
->afterStateUpdated(function (Event $event) {
if ($event->live == '1') {
$event->update(['live' => '0']);
$event->save();
}
}),
I have tried updateStateUsing, which doesn't seem to update the state as far as I can tell.
Tables\Columns\ToggleColumn::make('live')
->updateStateUsing(function (Event $event) {
$event->update(['live' => true]);
})
Tables\Columns\ToggleColumn::make('live')
->updateStateUsing(function (Event $event) {
$event->update(['live' => true]);
})
9 replies