Define a custom route with custom view in Filament

I would like to define a custom logic that will be executed after the user logs in. The idea is to show a similar design to the login page after the user logins. It will contain a dropdown menu and a submit button. The problem is that I'm unable to define the custom route anywhere. Can you please guide me where should I put such behaviour?
8 Replies
krekas
krekas2mo ago
create a custom page for that and hide it in the navigation
Melomancheto
MelomanchetoOP2mo ago
I don't want that page to inherit the design of the panel. I want it to be single window. I've managed to do this so far. But I had to define the following in the routes.php
Route::name('filament.')
->group(function () {
foreach (Filament::getPanels() as $panel) {
/** @var Panel $panel */
$panelId = $panel->getId();
$hasTenancy = $panel->hasTenancy();
$tenantRoutePrefix = $panel->getTenantRoutePrefix();
$tenantDomain = $panel->getTenantDomain();
$tenantSlugAttribute = $panel->getTenantSlugAttribute();
$domains = $panel->getDomains();

foreach ((empty($domains) ? [null] : $domains) as $domain) {
Route::domain($domain)
->middleware($panel->getMiddleware())
->name("{$panelId}." . ((filled($domain) && (count($domains) > 1)) ? "{$domain}." : ''))
->prefix($panel->getPath())
->group(function () use ($panel, $hasTenancy, $tenantDomain, $tenantRoutePrefix, $tenantSlugAttribute) {
foreach ($panel->getRoutes() as $routes) {
$routes($panel);
}

Route::name('organizations.select-organization')
->prefix('organizations')
->group(function () use ($panel) {
Route::get('/select', \App\Filament\Resources\OrganizationResource\Pages\OrganizationSelection::class)
->name('select');
});

});
}
}
});
Route::name('filament.')
->group(function () {
foreach (Filament::getPanels() as $panel) {
/** @var Panel $panel */
$panelId = $panel->getId();
$hasTenancy = $panel->hasTenancy();
$tenantRoutePrefix = $panel->getTenantRoutePrefix();
$tenantDomain = $panel->getTenantDomain();
$tenantSlugAttribute = $panel->getTenantSlugAttribute();
$domains = $panel->getDomains();

foreach ((empty($domains) ? [null] : $domains) as $domain) {
Route::domain($domain)
->middleware($panel->getMiddleware())
->name("{$panelId}." . ((filled($domain) && (count($domains) > 1)) ? "{$domain}." : ''))
->prefix($panel->getPath())
->group(function () use ($panel, $hasTenancy, $tenantDomain, $tenantRoutePrefix, $tenantSlugAttribute) {
foreach ($panel->getRoutes() as $routes) {
$routes($panel);
}

Route::name('organizations.select-organization')
->prefix('organizations')
->group(function () use ($panel) {
Route::get('/select', \App\Filament\Resources\OrganizationResource\Pages\OrganizationSelection::class)
->name('select');
});

});
}
}
});
Also the Page itself had to extend SimplePage But I don't know if this is the right way
No description
krekas
krekas2mo ago
instead of page it should extend the simplepage
Melomancheto
MelomanchetoOP2mo ago
and how can I define the route to that page? In the Resource? for example here:
public static function getPages(): array
{
return [
'index' => Pages\ListOrganizations::route('/'),
'create' => Pages\CreateOrganization::route('/create'),
'edit' => Pages\EditOrganization::route('/{record}/edit'),
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListOrganizations::route('/'),
'create' => Pages\CreateOrganization::route('/create'),
'edit' => Pages\EditOrganization::route('/{record}/edit'),
];
}
And just hide it in the navigation?
Melomancheto
MelomanchetoOP2mo ago
No description
Melomancheto
MelomanchetoOP2mo ago
When I add it to the getPages and it extends SimplePage
krekas
krekas2mo ago
Why would you add it to some resource pages?
Want results from more Discord servers?
Add your server