Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support changes to Methods in ModelHooks for inheritance #1199

Open
jenga201 opened this issue Apr 1, 2021 · 0 comments
Open

Support changes to Methods in ModelHooks for inheritance #1199

jenga201 opened this issue Apr 1, 2021 · 0 comments

Comments

@jenga201
Copy link

jenga201 commented Apr 1, 2021

The ModelHooks in #945 look great.
I'm hoping support for Methods could be also added. (or maybe I'm generating these PHP docs wrong, I'm not sure)

I've added a PR #1198 to support my use case.

My use case is;

A CommonModel with some general scope(s) defined

class CommonModel extends Model
{
    public function scopeConnection($query, $connectionName): CommonModel
    {
        $this->setConnection($connectionName);
        return $this;
    }
}

A Model that extends this CommonModel

class MyModel extends CommonModel
{
    protected $table = 'mymodel';
}

The generated PHP docs look like;
@method static \Illuminate\Database\Eloquent\Builder|CommonModel connection($connectionName)
Changing this line to return MyModel will give my IDE the ability to use the scope as needed and still retain the correct properties.
@method static \Illuminate\Database\Eloquent\Builder|MyModel connection($connectionName)

@jenga201 jenga201 changed the title Method Support changes to Methods in ModelHooks for inheritance Apr 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant