Skip to content

UI: Routing

Panel route registration, route names, and custom routes closure.

Panel routes register automatically when you call UI::panel(). Resource pages define paths relative to the resource slug.

Route naming

Pattern: streams.ui.{panelId}.{resourceSlug}.{pageName}

PostResource::getUrl('edit', ['entry' => $post->id]);
// streams.ui.admin.posts.edit

Resource page routes

public static function getPages(): array
{
    return [
        'index' => ListEntries::route('/'),
        'create' => CreateEntry::route('/create'),
        'edit' => EditEntry::route('/{entry}/edit'),
    ];
}

Panel path prefix

Panel::make('admin')->path('admin');
// /admin/posts, /admin/posts/create, ...

Custom routes

Pass a closure to ->routes() on the panel:

Panel::make('admin')
    ->path('admin')
    ->routes(function () {
        Route::get('/settings', SettingsPage::class);
    });

Standalone pages

Register page classes on the panel:

Panel::make('admin')->pages([DashboardPage::class]);

Standalone pages extend Streams\Ui\Livewire\Pages\PanelPage and define their own slug.

Related