staudenmeir / eloquent-has-many-deep

Laravel Eloquent HasManyThrough relationships with unlimited levels
MIT License
2.67k stars 157 forks source link

Composite Keys only in PHP 8? #175

Closed KingBier closed 2 years ago

KingBier commented 2 years ago

Hey there, thanks for the great enhancement for deep relationships. Pretty strong! Just a question: I have added it to my project with

composer require staudenmeir/eloquent-has-many-deep:"^1.7"

but there is no "Eloquent" folder in it and thus I cannot use CompositeKeys functionality. My PHP version is PHP 7.4 Is it not available for that or can it be made available for that version as well?

I have the following relationships: Review -> BelongsTo -> Recipe -> hasMany -> Conditions

tables: reviews, recipes_reviews, recipes_conditions, conditions

I believe that with hasManyDeep and CompositeKeys its possible to get all Conditions from the User of the single Review.

If there are any other methods please let me know.

Thanks in advance

staudenmeir commented 2 years ago

Hi @KingBier, Composite keys are only available for Laravel 9 at the moment. What version are you using?

What composite keys would you need to define in this case?

KingBier commented 2 years ago

thanks for your answer. maybe u can add the version requirement in the Readme. I use Laravel 8.

Ok, I found a solution without using composite keys but i had to restructure my db tables and queries. Now i can get the results i want.