idea-php-laravel-plugin icon indicating copy to clipboard operation
idea-php-laravel-plugin copied to clipboard

Support routes goto in namespaced route groups

Open codercms opened this issue 6 years ago • 3 comments

For example i have route service provider:

protected function mapApiRoutes()
{
    Route::middleware('api')
        ->namespace($this->namespace . '\Api')
        ->group(base_path('routes/api.php'));
}

And i have route group:

Route::group([
    'namespace' => 'Mirrors',
    'prefix' => 'lk',
    'middleware' => ['auth']
], function () {
    // Cert numbers
    Route::get('/cert_numbers', ['uses' => 'CertNumbersController@index']);
    Route::post('/cert_numbers', ['uses' => 'CertNumbersController@import']);
});

The full path to controller is - App\Http\Controllers\Api\Mirrors\CertNumbersController. But there is no working goto for these routes. Autocomplete suggest to use Api\Mirrors\CertNumbersController instead.

Can be this fixed? Or any workaround? Or maybe solution can be placed in plugin config, e.g. "Route files" (+we need to support "namespace" parsing in the Route::group).

codercms avatar Mar 06 '18 22:03 codercms

Workaround: remove ->namespace($this->namespace . '\Api') and add Route::group('namespace'=> 'Api') to the begin of api.php. It's very compicated to analyze route namespaces in these cases...

adelf avatar Mar 07 '18 06:03 adelf

@adelf can i suggest to add some annotation to specify namespace in routes file? E.g.

/** @laravel-idea-route-namespace \App\Http\Controllers\Api */

codercms avatar Mar 12 '18 03:03 codercms

I'm having this problem too. Where you able to find a workaround on it?

delmicio avatar Mar 23 '21 22:03 delmicio