Calling scopes after relationships not recognized.
Author: nickaguilarhCreated Oct 29, 2020Updated May 9, 2026
Labelsquestion
Versions:
- ide-helper Version: 2.8.1
- Laravel Version: 8.9.0
- PHP Version: 7.4.10
Question:
Hi there, I've been using this package for a long time now and I just noticed that when calling a scope from a relationship it is not detected. Is it the correct behavior?
Example: Email.php
public function mails(): BelongsToMany
{
return $this->belongsToMany(Mail::class);
}
public function scopeValid(Builder $query): Builder
{
return $query->where('status', '<>', 'blocked');
}Mail.php
public function emails(): BelongsToMany
{
return $this->belongsToMany(Email::class);
}Usage
$mail->emails()->active()->get()
Source: barryvdh/laravel-ide-helper