Basically, I try to do an update to one row in a table containing two primary keys. Primary keys are Trad_id and Trad_lang. For each differen row I want to update with the correct data, but Eloquent updates all rows with the same Trad_id.
Why is Eloquent updating all rows?
$tradInt = \Model\Traduction::where('Trad_id', $reference->Trad_id)->where("Trad_lang", "INTERNE")->first();
$tradInt->Trad_text = 'ABC';
$tradInt->save();
$tradExt = \Model\Traduction::where('Trad_id', $reference->Trad_id)->where("Trad_lang", "EXTERNE")->first();
$tradExt->Trad_text = 123;
$tradExt->save();
+---------+-----------+-----------+-----------+
| Trad_id | Trad_lang | Trad_type | Trad_text |
+---------+-----------+-----------+-----------+
| 1206 | INTERNE | | 123 |
| 1206 | EXTERNE | | 123 |
| 1206 | FR | | 123 |
+---------+-----------+-----------+-----------+
first()method will only ever return one item so are you sure it's updating more than one row in the DB per update statement? Trydd()the result of your query before updating so you can see what is being updated. Also, does your table require a composite primary key? Maybe that's what is causing the issue? - haakym