DEV Community

Horacio Degiorgi
Horacio Degiorgi

Posted on

3

Enlaces desde widgets

¿Cómo abrir recursos desde Cards en widgets?
Primero debe agregarse una acción "wire:click" mediante el método extraAttributes en la definición de la card.
El método debe estar definido en la clase como público y puede recibir parámetros.
Ejemplo (simplificado)

class StatsOverview extends BaseWidget
{
    protected static ?int $sort = 0;
    protected static ?string $pollingInterval = null;

    protected function getCards(): array
    {
        return [
            Card::make('Instituciones', Institution::count())->description('Instituciones')->color('success') ->extraAttributes([
                'class' => 'cursor-pointer',
                'wire:click' => 'golink("institutions")',
            ])
            ->descriptionIcon('heroicon-s-library'),
            Card::make('Bibliotecas', Library::count())->color('danger')->description('Bibliotecas ingresadas')->
            extraAttributes([
                'class' => 'cursor-pointer',
                'wire:click' => 'golink("libraries")',
            ])];

    }

        public function golink($resource){ 
        return   redirect()->route('filament.resources.'.$resource.'.index');
        }

}
Enter fullscreen mode Exit fullscreen mode

En el ejemplo ambos cards tienen enlace a sus páginas iniciales de "resources".

Image description

Image of Docusign

Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs