#Manually registering Filaments routes

42 messages · Page 1 of 1 (latest)

vapid glade
#

Is there a way to disable the automatic registration of routes with Filament, so that I can manually register them?

I don't want to build the routes myself, I just want to be able to have something like the following:

Route::middleware([...])
     ->prefix('...')
     ->group(function () {
         Filament::routes();
     });
jade pasture
#

What exactly do you want to do? You can group them already? That's what the path is... you can also add middleware with ->middleware()

So not sure what you want...

vapid glade
#

I was trying to find a way to do it that doesn't involve overriding stuff and hacking it about

#

It's a multitenancy thing that's outside of Filaments multitenancy functionality

jade pasture
vapid glade
jade pasture
# vapid glade What do you mean?

In the filament provider for the panel, you set the path. The path is the ID by default… like ‘admin’ all filament routes are grouped under that.

vapid glade
#

A very specific route group that is also automatically generated, and I don’t want to have to manually create it for every single panel

jade pasture
#

That sets it as a panel, but it also sets it as a group… just include the resources/pages in the additional panels?

vapid glade
#

I suspect I'm going to have extend Filament\Panel, which is fine

#

I was just hoping for something simpler

jade pasture
#

So Panel by default groups all resources and pages within that panel to it's $panel->id() if $panel->path() is not set. This is how we can have multiple panels with resources with the same names.

If you have multiple resources that you want to register in multiple panels then you can add more in the discorer i.e.

        ->discoverResources(in: app_path('Filament/AppPanel/Resources'), for: 'App\\Filament\\AppPanel\\Resources')
        ->discoverPages(in: app_path('Filament/AppPanel/Pages'), for: 'App\\Filament\\AppPanel\\Pages')
vapid glade
#

Except the problem is that I need to apply several routing characteristics to the panel, except I do not know them

jade pasture
#

Routing charachteristics like?

vapid glade
#

Yeah, domain, path, middleware, etc

#

Except I do not know them, and parts of the URI will sometimes have parameters in that I do not know the name of

jade pasture
#

The URL can have paths in the paths of the resource

#

But ideally you should be using query strings if need to pass in additional params.

#

you can also use ->moddle() to apply special routing charachteristics too.

vapid glade
#

I think you're misunderstanding what I need

#

I have a third-party package that automatically creates a route group for me

#

I want the filament panels I'm creating to exist within that route group

#

But at no point do I know the structure of that route group unless I run the route:list command and attempt to recreate it

jade pasture
#

So in the panel provider (panel) get the group string from your plugin, and pass that into the path of the panel.

vapid glade
#

The route group comes from here:

public function routes(Router $router, Closure $groupRoutes, Tenancy $tenancy): RouteRegistrar;
jade pasture
#

From what ever you are using to create the groups?

vapid glade
#

To create the groups I call this:

Route::tenanted(function () {
    // routes here
});
#

That is a mixin added to Router which does a whole host of things internally, including reading config to load and create a driver, before then asking that driver to create the route group

#

I do not have access to the details of the route group

#

The third-party package is mine, but I'm not adding the functionality to do that

#

I'm trying to create a nice way to make Filament work with my multitenancy package, and because of how the package works, it doesn't need to touch Filaments multitenancy functionality

jade pasture
#

Right so you want Filament to be under your package opposed to at the route, but because filament was designed to be an admin panel we set our own rights at the primary level

vapid glade
#

Sort of, yes

#

Honestly, I could probably create a very quick PR for Filament that would allow you to do this, however, I assume that there's no desire for that since it can't already be done

#

I'll create a compatibility plugin that overrides a few things

jade pasture
#

Cool, you'll be surpirsed how open dan is to PRs that are low maintenance

vapid glade
#

It would be low maintenance, but most likely changes a fundamental base part

#

I'll probably throw the problem at Alex anyway, see if he has some secret insider knowledge I don't lol