laravel-idea / plugin

Laravel Idea plugin for PhpStorm
https://laravel-idea.com/
176 stars 7 forks source link

[Feature Request]: Helper code generation consider specific vendor package #911

Closed henryavila closed 3 weeks ago

henryavila commented 10 months ago

Feature Description

I have a app that divide the same codebase.

To don't duplicate code, I've created a private package that contain all models and all code that are used by more then on app.

The problem with Laravel Idea is that the Helper code completely ignore my package with all my models, making the helepr conde useless for me.

If in config, I could define what vendor should be used when generating helper code, this feature will be usefull for me

adelf commented 9 months ago

Hello. I checked your case. I think it should work. My code for models fetching. A bit ugly, but... do your models in \Illuminate namespace?

fun PhpIndex.getAllEloquentModels(): Sequence<PhpClass> {
    return getAllSubPhpClasses(EloquentSpecificClasses.eloquentModelClass)
        .filter {
            it.isReal()
                && (!it.fqn.startsWith("\\Illuminate\\") || it.fqn == "\\Illuminate\\Notifications\\DatabaseNotification")
                && it.fqn != "\\Eloquent"
        }
}
henryavila commented 9 months ago

Hi @adelf, thanks for reply.

I work in two projects with the same idea.

In one case, My model namespace looks like: VirtualSda\ChurchFramework\Models\Tenants.

So, in the apps that use this private package, I can use The model directly from the private package, like:

VirtualSda\ChurchFramework\Models\Tenants\Calendar::first() or create a local model That extends the package model:

namespace App\Models\Tenants;

class Calendar extends \VirtualSda\ChurchFramework\Models\Tenants\Calendar {

    // class customization
}

And when using App\Models\Tenants\Calendar , laravel idea should get the content of local and the private package model

This is a example for one project. The other one has the same ide, Just the namespace of private package that are different

adelf commented 9 months ago

I tried different cases, and it worked in each of them. Does PhpStorm have access to these classes? Can you find them by Find class(Cmd-O) action?