Ok, this thing is so weird I have zero explanation for it, but here's the solution:
-
First of all you need to explicitly update
updated_atyourself, because otherwise Laravel would try and do it itself and make a big mess out of everything. -
For some unknown reason the initial setup simply failed to assign the variables to the placeholder
?:DB::raw("REPLACE(hierarchy, ?, ?)", [$old_hierarchy, $new_hierarchy]) -
I had to do it using
setBindings, but on top of that couldn't assign all of them through this method because they would have gotten messed up once again, so only did it for theDB::rawstatements.
Category::setBindings([$old_hierarchy, $new_hierarchy, now()])
->whereRaw("hierarchy LIKE ?", [$old_hierarchy . '>%'])
->update([
'hierarchy' => DB::raw("REPLACE(hierarchy, ?, ?)"),
'updated_at' => DB::raw("?")
]);
If anyone has any explanation of this whole crazy thing, please let me know