laravel-goto-controller
laravel-goto-controller copied to clipboard
Include namespace directory to Controller path and go to method in the controller
Nice work this does for me but I will like to report two major issues
- It would be great if we could go to method rather than just going to the controller. This is definitely an enhancement.
- 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
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
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.
I needed this in most of my projects and coded an extension for that - https://marketplace.visualstudio.com/items?itemName=freshbitsweb.laravel-traveller
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');
});
Unfortunately I don't have time to work on this feature, PRs are always welcomed.
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 😅