plugin icon indicating copy to clipboard operation
plugin copied to clipboard

[Bug]: Go to declaration not working on policy when using "simple directory module system"

Open Tristan-MyAnaPro opened this issue 10 months ago • 2 comments

Bug description

When using the "simple directory module system", policies "go to" and "view usage" functionality are not working if the policies and models are placed inside the module, despite Laravel auto discovery of the policies working perfectly.

Image

Image

Everything in Laravel Idea seems to be hardcoded to search in Models and Policies of the root directory.

On the same note, the "search related classes" don't work either if the policies are not in the root directory of the project:

Image

Plugin version

10.0.3.243

Operating system

Linux

Steps to reproduce

Repository demonstrating the problem: https://github.com/Tristan-MyAnaPro/laravel-idea-issue-policy-module

Configure Laravel Idea to use the "simple directory module system"

Image

Place a model and a related policy inside the module.

Try to use "go to definition" on a can(...) or "view usage" on the policy check.

Relevant log output

N/A

Tristan-MyAnaPro avatar Feb 24 '25 15:02 Tristan-MyAnaPro

Hi @adelf,

Sorry to ping you like that but I feel like 4 month without a response gives me the permission to 🤭

Just so you know, this problem still exists in Laravel Idea version 10.2.2.251.

We are not using the "Simple directory modules" anymore but the "Directory modules as composer.json packages".

Image

Registering the policy manually inside the service provider (Gate::policy(MyModel::class, MyModelPolicy::class); fix the problem but it defeat the purpose of policy auto discovery and nice DX offered by Laravel 😿

Hope you can find a solution! Thanks for you work 💪

Tristan-MyAnaPro avatar Jun 18 '25 08:06 Tristan-MyAnaPro

I added this to internal task tracker, thanks!

gorbunov avatar Jun 20 '25 05:06 gorbunov