Update in Laravel 5 a field receiving the value of another field from the same table

3

I have a configuration table in my database that has the following fields: ["id", "texto", "textoOriginal"] . Initially the values of the texto field are equal to the textoOriginal field, but the user can at any given time change the value of the texto field. I need to create a method that the user can reset the original values of the parameters, so I need to run this query:

UPDATE parametros SET texto = textoOriginal

But I wanted to do this through the Query Builder syntax , it turns out that Laravel updates the texto field with the string " OriginalType " . I'm doing this:

$this->update(['texto' => 'parametros.textoOriginal']);

Does anyone know how to do this?

    
asked by anonymous 22.05.2015 / 23:12

1 answer

3

I was able to solve the problem. For those with the same problem, just put the field name in the expression DB :: raw ('column_name') like this:

$this->update(['texto' => DB::raw('textoOriginal')]);
    
25.05.2015 / 19:24