Skip to content

How to redirect from stats widget on click? #8057

Discussion options

You must be logged in to vote

Figured it out! Working code example:

class Test extends BaseWidget
{
    protected static ?string $pollingInterval = null;

    protected function getStats(): array
    {
        return [
            Stat::make('Test', 1234)
                ->extraAttributes([
                    'class' => 'cursor-pointer',
                    'wire:click' => 'goto()',
                ]),
        ];
    }

    public function goto()
    {
        return redirect()->to('/test');
    }
}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@chiragpatel2595
Comment options

@leandrocfe
Comment options

Answer selected by anatolyeltsov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants