EloquentQuery Type Hinting
Hello, I have this block working fine:
But phpstan throws this:
Call to an undefined method Illuminate\Database\Eloquent\Builder::withAuthNumber()
Method is declared on model:
@method static Builder|Billing withAuthNumber()
Someone help, please.
/**
* @return Builder<Billing>
*/
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->withAuthNumber();
}
But phpstan throws this:
Call to an undefined method Illuminate\Database\Eloquent\Builder::withAuthNumber()
Method is declared on model:
@method static Builder|Billing withAuthNumber()
/**
* @param Builder<Billing> $query
* @return Builder<Billing>
*/
public function scopeWithAuthNumber(Builder $query): Builder
Someone help, please.
Solution
Thank you Povilas! The way I resolved this was calling the scope on the model's booted method. 