Use Macroable or allowing somehow to add custom attributes to RouteRegistrar

80 Views Asked by At

I'm doing this:

    \Illuminate\Routing\Route::macro('description', function (string $description): AppServiceProvider|\Illuminate\Routing\Route {
        $this->action['description'] = isset($this->action['description']) ? $this->action['description'].$description : $description;
        return $this;
    });

So I can do this:

Route::post('/test', [TestController::class, 'test'])->description('this is a test description');

Then I will access the description as normally should by:

$request->route()->getAction('description');

The problem I'm facing is that if we add a new mixin/macro on Illuminate\Routing\Route, it cannot be accessed from RouteRegistrar because the $allowedAttributes are hardcoded.

Any work around for this?

0

There are 0 best solutions below