thefireflytech / filament-blog

Blog plugin for laravel filament
https://packagist.org/packages/firefly/filament-blog
Other
86 stars 36 forks source link

Does this package support locale? #37

Closed CharlieBrownCharacter closed 1 month ago

CharlieBrownCharacter commented 1 month ago

Hey y'all 👋

First of all, thank you very much for such an amazing package. I'm trying to add locale to my project and looking in https://github.com/thefireflytech/filament-blog/blob/4b01f72d16e1e750e7c0e8cd848a437bd629c826/routes/web.php#L9 it looks like we could simply use route.prefix in filamentblog.php configuration file but when adding {locale}/blogs there, it breaks in the view because when calling route() it expects a locale to be passed.

<?php

use App\Models\User;

return [
    'route' => [
        'prefix' => '{locale}/blogs',
       // ...
    ],
   // ...
];
Missing required parameter for [Route: filamentblog.post.show] [URI: {locale}/blogs/{post}] [Missing parameter: locale].

resources/views/vendor/filament-blog/components/feature-card.blade.php :9

<a href="{{ route('filamentblog.post.show', ['post' => $post->slug]) }}" class="mb-4 block text-xl md:text-4xl font-semibold hover:text-blue-600">
  {{ $post->title }}
</a>

Is there any way I can make this package support locale?

CharlieBrownCharacter commented 1 month ago

One way might be to override the global route to check if we have a locale and add it but this seems a bit odd.

CharlieBrownCharacter commented 1 month ago

Was not aware we can use URL::defaults(['locale' => $request->user()->locale]);.

This is described in the docs. https://laravel.com/docs/11.x/urls