Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App breaking on L 5.7.16 with hasManyThrough? #26768

Closed
lpeterke opened this issue Dec 6, 2018 · 7 comments
Closed

App breaking on L 5.7.16 with hasManyThrough? #26768

lpeterke opened this issue Dec 6, 2018 · 7 comments

Comments

@lpeterke
Copy link

lpeterke commented Dec 6, 2018

I was wondering if the fixes for hasManyThrough that have been introduced in 5.7.16 are a breaking change? In one of my apps I had this relation:

public function parentModels(){
  return $this->hasManyThrough(Model::class, SubModel::class, 'sub_model_id', 'model_id', 'id', 'id');
}

needed to change it like this to make my app work with 5.7.16:

public function parentModels(){
  return $this->hasManyThrough(Model::class, SubModel::class, 'sub_model_id', 'id', 'id', 'model_id');
}
@driesvints
Copy link
Member

Related to this PR? #26676

Ping @staudenmeir

@lpeterke
Copy link
Author

lpeterke commented Dec 6, 2018

One used query was this:

$model = Model::where('key', $key)->with('parentModels')->first();

Here is the SQL Exception that I got:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'models.model_id' in 'on clause' (SQL: select `models`.*, `sub_models`.`sub_model_id` from `models` inner join `sub_models` on `sub_models`.`id` = `models`.`model_id` where `sub_models`.`sub_model_id` in (1))

@staudenmeir
Copy link
Contributor

Can you provide an example with "real" models? Is SubModel a subclass of Model?

@lpeterke
Copy link
Author

lpeterke commented Dec 6, 2018

It is not a subclass, both are Eloquent model classes

@staudenmeir
Copy link
Contributor

staudenmeir commented Dec 6, 2018

Please provide an example with real models and their migrations. Or at least the migrations for your example.

@GrahamCampbell
Copy link
Member

Ping @apocalyarts. We need more information please.

@driesvints
Copy link
Member

@apocalyarts feel free to reply once you can provide more info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants