1

Using laravels magic with scopes I can typehint the scope name as it is used in the code (hasName). However it will then not be picked up by the IDE, if the scopeHasName is being used and where it is used. Is there some way to "alias" those two. I.e. telling the IDE that "hasName" is actually implemented in "scopeHasName"?

/** @method static Builder hasName(Builder $q) **/
class User extends Model {
    public function scopeHasName($q)
    {
        return $q->whereNotNull('name');
    }
}

$user = User::hasName()->first();
Chris
  • 13,100
  • 23
  • 79
  • 162
  • Which IDE You using out of curiosity? – Dale Feb 04 '22 at 19:00
  • Maybe this can help? https://github.com/barryvdh/laravel-ide-helper – Simon K Feb 04 '22 at 19:01
  • @Dale I am using PhpStorm – Chris Feb 04 '22 at 19:03
  • @SimonK I am already using the ide helper, but it does not cover this case – Chris Feb 04 '22 at 19:03
  • I was hoping so, a man of culture I see :) check out this plugin, no guarantees it does what you want but its blown me away in the last few weeks, https://plugins.jetbrains.com/plugin/13441-laravel-idea , unfortunately not free but it's got a trial – Dale Feb 04 '22 at 19:04

0 Answers0