biiiiiigmonster / hasin

The 'hasin' is an imitator of 'has' in laravel orm relationships, but it's faster.
MIT License
136 stars 13 forks source link

(Laravel 11) Error: HasOneThrough must be a relationship instance #51

Closed nicholaszuccarelli closed 4 weeks ago

nicholaszuccarelli commented 4 weeks ago

I'm having trouble getting the package working with Laravel 11 We recently did a Laravel 9 => 10 upgrade and the package worked fine, however with Laravel 11, some of my queries are failing with Illuminate\Database\Eloquent\Relations\HasOneThrough must be a relationship instance

As an example, I have a Company, Billable and Subscription model.

Company has a hasOneThrough relationship as such:

public function subscription()
    {
        return $this->hasOneThrough(
            Subscription::class,
            Billable::class,
            'model_id',
            'billable_id',
            'id',
            'id'
        );
     }

I then attempt to get the total companies who are subscribed using: $totalCompaniesSubscribed = Company::whereHasIn('subscription')->count() This line^ produces the error.

image

If I change the line to instead use the traditional ::whereHas('subscription') it works, but as we know that can have performance degradation.

biiiiiigmonster commented 4 weeks ago

Thanks feedback!

Yeah, it seems to have problem on the laravel-11, I will fix it later.

biiiiiigmonster commented 4 weeks ago

The issue fixed with package v4.0.1, then I will close it.

If you meet others problems, welcome feedback!

nicholaszuccarelli commented 4 weeks ago

Thank you so much for the speedy fix. Love the package btw.