mardi 10 octobre 2017

Laravel after update (5.3 => 5.4) produces wrong sql

I have stable project with Laravel 5.3.

Today decided to upgrade Laravel to 5.4 and then to 5.5. I am following to official upgrade guide.

After 5.4 upgrade everything seems to work.. except one thing. One of my multiple belongsToMany relationships produces now wrong sql.

I have model App\Situation with relationship:

public function feedbacks()
  {
    return $this->belongsToMany('App\Feedback');
  }

And App\Feedback model with:

public function situations()
  {
    return $this->belongsToMany('App\Situation');
  }

Of course I have tables feedbacks, situations and feedback_situation. Before upgrade this code was fine:

dd($situation->feedbacks);

But now it produces exception:

Base table or view not found: 1146 Table 'example.feedback' doesn't exist (SQL: select feedback.*, feedback_situation.situation_id as pivot_situation_id, feedback_situation.feedback_id as pivot_feedback_id from feedback inner join feedback_situation on feedback.id = feedback_situation.feedback_id where feedback_situation.situation_id = 383)

It's very weird because other relationships works, and this one worked on 5.3.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire