F
Filamentβ€’16mo ago
AmauryCid

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:
Thank you Povilas! The way I resolved this was calling the scope on the model's booted method. πŸ˜€
Jump to solution
4 Replies
Povilas K
Povilas Kβ€’16mo ago
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
AmauryCid
AmauryCidβ€’16mo ago
Thank you Povilas! The way I resolved this was calling the scope on the model's booted method. πŸ˜€
Povilas K
Povilas Kβ€’16mo ago
Good workaround πŸ™‚
AmauryCid
AmauryCidOPβ€’16mo ago
I did the steps on the stack overflow article, but for my implementation, it didn't work
Want results from more Discord servers?
Add your server