larastan / larastan

⚗️ Adds code analysis to Laravel improving developer productivity and code quality.
MIT License
5.53k stars 416 forks source link

Call to an undefined method Illuminate\Database\Eloquent\Relations\MorphTo::using() #1836

Closed netdjw closed 9 months ago

netdjw commented 9 months ago

Description

I get this error:

Call to an undefined method Illuminate\Database\Eloquent\Relations\MorphTo<Domain\Product\Models\Color, Domain\Product\Models\Price>::using().

Laravel code where the issue was found

    /**
     * Get the color that owns the price.
     *
     * @return \Illuminate\Database\Eloquent\Relations\MorphTo<Color, Price>
     */
    public function color(): MorphTo
    {
        return $this->morphTo(Color::class, 'colorizable')->using(Colorizable::class);
    }

Is there any trick to fix this?

mad-briller commented 9 months ago

What Laravel version are you on? i can't find any reference to the morphTo::using() method in laravel 10.x but i could be missing something.

calebdw commented 9 months ago

There's nothing to do here, using is only defined on the BelongsToMany (and therefore MorphToMany) relation.

netdjw commented 9 months ago

Thank you guys! I'm really precious for your help!