laravel-goto-controller icon indicating copy to clipboard operation
laravel-goto-controller copied to clipboard

Include namespace directory to Controller path and go to method in the controller

Open simioluwatomi opened this issue 7 years ago • 6 comments

Nice work this does for me but I will like to report two major issues

  1. It would be great if we could go to method rather than just going to the controller. This is definitely an enhancement.
  2. In my current project, I have a multi-auth setup and to implement this, I copied all of laravel's default auth controllers into a new namespace and overrode their methods. So in essence, I have some controllers with the same name but in different directories.

E.g

Route::group(['namespace' => 'Web\Auth'], function () {
    Route::get('/password/reset', 'ForgotPasswordController@showLinkRequestForm');
    Route::post('/password/email', 'ForgotPasswordController@sendResetLinkEmail');
    Route::post('/password/reset', 'ResetPasswordController@reset');
    Route::get('/password/reset/{token}', 'ResetPasswordController@showResetForm');
});

But when I want to go to these sets of controllers, the extension does not factor in the namesapce at the top of the route group into the path of the controllers. The result is that I am taken to the default laravel auth controllers located in App\Http\Controllers\Auth.

Thanks for the extension once again

simioluwatomi avatar Jan 31 '18 20:01 simioluwatomi

i think what u need is only doable with a language server but as the extension is currently a regex based it wont be possible unless @stef-k have a better idea

ctf0 avatar May 03 '19 21:05 ctf0

I think it could be done to some level. The disadvantage of this approach is that all the search and resolve to link is done at editor/project startup/load. With language server the process of resolving new symbols is async and continuous.

Unfortunately I haven't much free time to work on new features; any PRs will be welcomed though.

stef-k avatar May 04 '19 07:05 stef-k

I needed this in most of my projects and coded an extension for that - https://marketplace.visualstudio.com/items?itemName=freshbitsweb.laravel-traveller

gauravmak avatar Apr 03 '20 05:04 gauravmak

I noticed the same issue on my project. I use groups with namespaces and the extension gets only the Admin controllers, because the controllers have the same name but are in different groups.

Example:

/**
 * Admin Section
 */
Route::group([
    'prefix' => 'admin',
    'namespace' => 'Admin'
], function () {
Route::get('orders', 'OrderController@orders')->name('orders');
});

/**
 * User Section
 */
Route::group([
    'prefix' => 'user',
    'namespace' => 'User'
], function () {
Route::get('orders', 'OrderController@orders')->name('orders');
});

weidmaster avatar Oct 28 '20 14:10 weidmaster

Unfortunately I don't have time to work on this feature, PRs are always welcomed.

stef-k avatar Oct 28 '20 16:10 stef-k

Unfortunately I don't have time to work on this feature, PRs are always welcomed.

Well that is my cue to learn Typescript and VSCode extension development. I would love to help improve useful extensions like yours, I just don't know how. But I will take a look.

I am not sure about how to find the correct method, but for the namespace issue I do have an idea how it could be solved. It is basic searching for the namespace key in the group and applying on the search for the controller. At least on paper it is easy 😅

weidmaster avatar Oct 28 '20 16:10 weidmaster