EloquentQuery Type Hinting
Hello, I have this block working fine:
/**
* @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:Jump to solution
Thank you Povilas! The way I resolved this was calling the scope on the model's booted method. π
4 Replies
Stack Overflow
Fix Laravel scope warnings of phpstan (or larastan)?
How to deal with scopes in Laravel when analyzing code with phpstan/larastan?
I'm getting this error:
Call to an undefined method Illuminate\Database\Eloquent\Builder::active().
Do I need to typeh...
Solution
Thank you Povilas! The way I resolved this was calling the scope on the model's booted method. π
Good workaround π
I did the steps on the stack overflow article, but for my implementation, it didn't work