<div> <div wire:poll.10s class="flex items-center justify-end"> @if ($this->syncAction->isVisible()) {{ $this->syncAction }} @endif </div> <x-filament-actions::modals /></div>
class SyncStatusButton extends Component implements HasForms, HasActions{ use InteractsWithActions, InteractsWithForms; public ?Product $record = null; public function render() { return view('filament.livewire.trendyol.sync-status-button'); } public function syncAction(): Action { return Action::make('sync') ->label('Eşleşme') ->link() ->color('danger') ->icon('heroicon-o-x-mark') ->visible(fn () => $this->record && $this->record->trendyol) ->form([ Checkbox::make('delete_data') ->label('Veriyi de sil') ->helperText('İşaretlenirse ürün verisi de silinir.') ]) ->action(function($data) { foreach ($this->record->variants as $variant) $variant->trendyol->unsync($data["delete_data"]); return redirect($data["delete_data"] ? ProductResource::getUrl('index') : ProductResource::getUrl('edit', ['record' => $this->record])); }); }}