Defining Additional parameters on URL

In my app I have locations, and there's a relationship to month ends. When navigating, I'd like to have my urls be like this as an example:

/locations/{location_id}/month-end/202311

The only way that I've seen it work is more like /locations/{location_id}/month-end?yearMonth=202311, which is fine I guess, but I was hoping there is an easy way to not use url parameters if I don't have to.

I've tried modifying the $slug property in my resource class, which seems to have some effect, but then I get an error that I'm missing parameters location and yearMonth.

If I supply those paremeters it seems to get angry that I haven't supplied the record parameter.

I'm a little confused about how the urls are defined as I'm used to just defining them explicitly in the web.php routes file.

class MonthEndTaskResource extends Resource
{
    protected static ?string $model = MonthEndTask::class;

    protected static ?string $navigationIcon = 'heroicon-o-calendar-days';

    protected static bool $shouldRegisterNavigation = false;

    // protected static ?string $slug = 'locations/{location}/month-end/{yearMonth}'; <--this causes problems.

   ...    

    public static function getPages(): array
    {
        return [
            'index' => Pages\ListMonthEndTasks::route('/'),
            'create' => Pages\CreateMonthEndTask::route('/create'),
            'edit' => Pages\EditMonthEndTask::route('/{yearMonth}'),
        ];
    }
Solution
e.g.
image.png
Was this page helpful?