phptools-docs icon indicating copy to clipboard operation
phptools-docs copied to clipboard

Local Query Scope Support [FEATURE REQUEST]

Open Maaz0313 opened this issue 1 year ago • 1 comments

Please add support for Laravel's local query scope methods, so that Eloquent methods can be suggested after it. Relevant link

Maaz0313 avatar Jun 25 '24 20:06 Maaz0313

Thank you for the suggestion!

We should already do that: vscode-eloquent-local-scopes

Is there anything specific where it doesn't work? Is it Laravel >= 9? Do all the methods have a correct mouse hover?

jakubmisek avatar Jun 26 '24 12:06 jakubmisek

@jakubmisek Hello.

About scopes, in Laravel 12, we have a new attribute to define a function as local scope: #[Scope].. You can see the documentation here Laravel Local Scopes.

Image

The extension doesn't recognize the function as a scope. And asks for the Builder parameter.

Image

Also we have another attribute to identify a Model as scoped: #[ScopedBy([AncientScope::class])].

Image

Can you add support for this?

trollfalgar avatar Jun 13 '25 12:06 trollfalgar

Thank you @trollfalgar - will be added!

jakubmisek avatar Jun 15 '25 18:06 jakubmisek

@trollfalgar does the scoped model have some extra IntelliSense?

I.e. all the local scope methods from the "AncientScope" should be listed as a member of User ?

jakubmisek avatar Jun 15 '25 18:06 jakubmisek

@trollfalgar does the scoped model have some extra IntelliSense?

I.e. all the local scope methods from the "AncientScope" should be listed as a member of User ?

@jakubmisek in global scopes, like the exemple #[ScopedBy([AncientScope::class])] (Or the old way to do it), the only method needed is apply(), and automatically the scope is always applied. So I don't think any method should be listed in IntelliSense.

In local scopes, yes, should keep listing the method name, recognizing the parameters (ignoring the dependency injection Builder.

trollfalgar avatar Jun 16 '25 12:06 trollfalgar

Hello, @jakubmisek, any news about this? 🙏

trollfalgar avatar Jul 11 '25 14:07 trollfalgar

@trollfalgar thanks for reminding me, yes, support for the #[Scope] attribute has been implemented - already in the pre-release (with a few fixes in the next pre-release)

jakubmisek avatar Jul 11 '25 14:07 jakubmisek