moonshine-software / moonshine

Laravel Admin panel and more. Simple for beginners and powerful for experts. Using Blade, Alpine.js and Tailwind CSS.
https://moonshine-laravel.com
MIT License
759 stars 100 forks source link

feat: Events with query #1208

Closed lee-to closed 2 months ago

lee-to commented 2 months ago
public function components(): array
    {
        $components = request()->has('id')
            ? [
                FlexibleRender::make("Condition #" . request()->input('query.id')),
            ]
            : [
                FlexibleRender::make("Empty condition"),
            ];

        return [
            ActionButton::make('Change fragment', fn($id) => "?id=$id")
                ->setItem(30)
                ->dispatchEvent(
                    AlpineJs::event(JsEvent::FRAGMENT_UPDATED, 'main-page-fragment', ['id' => 3])
                )
            ,

            Fragment::make($components)
                ->name('main-page-fragment')
            ,
        ];
    }