Enable disabled button after creating related item

I have the following action on my resource, and as you can see it is checking if the record has 1 or more rounds connected to it. In the gui the action is displayed above the table where the rounds are displayed via a relationmanager. Can I make this disabled/enabled state change interactive, so I dont have to actually reload the page after adding another round(s)? Any help would be much appreciated. Thank you in advance.
<?php
Actions\Action::make('markAsFinished')
->label('Mark as Finished')
->action(function () {

$this->record->update([
'finished' => true,
'winner_id' => $this->record->rounds()->select('winner_id')->groupBy('winner_id')->orderByRaw('COUNT(*) DESC')->first()->winner_id,
]);
return redirect()->route('filament.dashboard.resources.games.view', ['record' => $this->record->id]);
})
->requiresConfirmation()
->color('success')
->disabled(fn() => $this->record->rounds()->count() === 0);
<?php
Actions\Action::make('markAsFinished')
->label('Mark as Finished')
->action(function () {

$this->record->update([
'finished' => true,
'winner_id' => $this->record->rounds()->select('winner_id')->groupBy('winner_id')->orderByRaw('COUNT(*) DESC')->first()->winner_id,
]);
return redirect()->route('filament.dashboard.resources.games.view', ['record' => $this->record->id]);
})
->requiresConfirmation()
->color('success')
->disabled(fn() => $this->record->rounds()->count() === 0);
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?