Laravel-ide-helper: ide-helper:models doesn't generate protected scope() method and attribute() property

Created on 6 Nov 2019  路  5Comments  路  Source: barryvdh/laravel-ide-helper

ide-helper:models can generate methods and properties for "public" scopes and attributes, but not protected one.

Here is the example model:

class User extends Model
{
    public function scopeBoy() { ... }
    protected function scopeGirl() { ... }
    public function getMidNameAttribute() { ... }
    protected function getLastNameAttribute() { ... }
}

ide-helper:models only generate "public" scope and attribute:

/**
 * Class User
 * @property-read string midName
 * @method static User boy()
 */
class User { }
stale

All 5 comments

Why would you like to have non-public methods/attributes added to autocompletion? You cannot access them from the outside, except in child classes (protected methods/attributes), so having that added to the docblock is pointless.

Model's scope and attribute-related functions can't be called directly. If they are declared as public, IDE tools will auto-complete these functions. Declaring as 'protected' will prevent this but also work for laravel.

Model's scope and attribute-related functions can't be called directly.

Um, why? Besides, local scopes must be declared as public.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this issue is still present on the latest version of this library on supported Laravel versions, please let us know by replying to this issue so we can investigate further.
Thank you for your contribution! Apologies for any delayed response on our side.

Not sure if it's required, but that is how it's done in the docs. I guess this is an edge-case.
https://laravel.com/docs/7.x/eloquent#local-scopes

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ttomdewit picture ttomdewit  路  5Comments

hatamiarash7 picture hatamiarash7  路  3Comments

kickthemooon picture kickthemooon  路  3Comments

Newbie012 picture Newbie012  路  4Comments

beniaminorossini picture beniaminorossini  路  5Comments