filter = $filter; if ($this->filter && $this->filter[1] > 0) { Notification::make('fix_error') ->title('Product sync error correction has begun.') ->body('After some time, please refresh the page.') ->info() ->send(); Artisan::call('fix-product-errors-based-on-general-logs'); } else { Notification::make('fix_error') ->title('There are no errors.') ->danger() ->send(); } } protected function getStats(): array { $errorCount = Product::where('is_error', true)->count(); return [ Stat::make('Product Sync Errors', $errorCount) ->description('Number of products with sync errors') ->color('danger') ->extraAttributes([ 'class' => 'relative cursor-pointer', 'x-data' => '{}', 'role' => 'button', 'tabindex' => '0', 'aria-label' => 'Filter Product Sync Errors', 'x-init' => " let button = document.createElement('button'); button.className = 'absolute top-0 right-0 mt-2 mr-2 px-2 py-1 text-sm text-white bg-blue-500 rounded hover:bg-blue-600'; button.setAttribute('aria-label', 'Fix Errors'); button.innerText = 'Fix Errors'; button.setAttribute('wire:click', `\$dispatch('setStatusFilter',{ filter: ['processed', {$errorCount}]})`); \$el.appendChild(button); ", ]), ]; } }