Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Routes do not have route prefixes when set in web.php #17

Closed
arduinomaster22 opened this issue Jan 13, 2025 · 6 comments · Fixed by #23
Closed

[Bug]: Routes do not have route prefixes when set in web.php #17

arduinomaster22 opened this issue Jan 13, 2025 · 6 comments · Fixed by #23
Assignees
Labels
bug Something isn't working

Comments

@arduinomaster22
Copy link
Contributor

What happened?

When this is set in the web.php file, this does not have the prefixes of routes like the routes that are registered through the Filament Panel.

FilamentMails::routes();

How to reproduce the bug

Add:

FilamentMails::routes();

to web.php in any Laravel app.

Package Version

2.0.0

PHP Version

8.2.0

Laravel Version

11.0.0

Which operating systems does with happen with?

No response

Notes

No response

@arduinomaster22 arduinomaster22 added the bug Something isn't working label Jan 13, 2025
@arduinomaster22 arduinomaster22 self-assigned this Jan 13, 2025
@markvaneijk markvaneijk changed the title [Bug]: [Bug]: Routes do not have route prefixes when set in web.php Jan 13, 2025
@Baspa
Copy link
Member

Baspa commented Jan 13, 2025

Which prefixes are missing? @arduinomaster22

@dgironella
Copy link

Same problem, include FilamentMails::routes(); on web.php generate this routes:

mails/{mail}/attachment/{attachment}/{filename} ................................................................................................... mails.attachment.download › Vormkracht10\FilamentMails › MailDownloadController
mails/{mail}/preview ........................................................................................................................................... mails.preview › Vormkracht10\FilamentMails › MailPreviewController

But on mail preview this route is call: Route [filament.admin.mails.preview] not defined.

@Baspa
Copy link
Member

Baspa commented Jan 15, 2025

@arduinomaster22 do you have any time to a look at it? Or should I check it?

@cntabana
Copy link

cntabana commented Jan 29, 2025

I encountered an issue with FilamentMails::routes(), where the route names did not align with my Filament admin panel structure. To resolve this, I temporarily commented out FilamentMails::routes() and manually defined the routes with adjusted names

use Vormkracht10\FilamentMails\Controllers\MailDownloadController;
use Vormkracht10\FilamentMails\Controllers\MailPreviewController;

//FilamentMails::routes();

Route::get('mails/{mail}/previews', MailPreviewController::class)
              ->name('filament.admin.mails.preview');

Route::get('mails/{mail}/attachment/{attachment}/{filename}', MailDownloadController::class)
               ->name('filament.admin.mails.attachment.download');

This fix ensures the routes are properly prefixed under filament.admin. However, it would be great to have a way to customize route names directly from the package to avoid modifying core behavior. Let me know if there's a better approach!

@Baspa Baspa linked a pull request Feb 4, 2025 that will close this issue
@markvaneijk
Copy link
Member

markvaneijk commented Feb 6, 2025

public static function routes(?string $path = null, ?string $name = null): void
{
    $path = $path !== null ? $path : filament()->getDefaultPanel()->getPath();
    $name = $name !== null ? $name : 'filament.'.filament()->getDefaultPanel()->getId();

    Route::prefix($path)
        ->name($name)
        ->group(function () {
            Route::get('mails/{mail}/preview', MailPreviewController::class)->name('mails.preview');
            Route::get('mails/{mail}/attachment/{attachment}/{filename}', MailDownloadController::class)->name('mails.attachment.download');
        });
}

I think something like this could be it @Baspa

@Baspa Baspa closed this as completed in #23 Feb 7, 2025
@markvaneijk
Copy link
Member

@cntabana @cntabana fixed in v2.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants