Magalliu's avatar

Using Macroable or allowing somehow to add custom attributes to RouteRegistrar

I'm doing this:

\Illuminate\Routing\Route::macro('description', function (string $description) {
        $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.

0 likes
0 replies

Please or to participate in this conversation.