I'd like to update only the fields that were changed(but I'm passing all fields), like the method fill(). But, When I do this in polymorphic relations, it doesn't work.
Fill():
$this->empresa->fill($input)->save();
ex: updating only updated_atfield: Log:
> `update `empresas` set `updated_at` = ? where `id` = ? [["2017-08-24
> 11:26:04",1],0.31]`
but in child, even if I change only 1 field, the model updates all fields.
$empresa->contatos()->update($input);
Log:
> update `contatos` set `endereco` = ?, `numero` = ?, `bairro` = ?,
> `cep` = ?, `cidade` = ?, `complemento` = ?, `tipo_end` = ?,
> `estado_id` = ?, `updated_at` = ? where `contatos`.`contatoable_id` =
> ? and `contatos`.`contatoable_id` is not null and
> `contatos`.`contatoable_type` = ? [["Rua Um","2145","Vila
> Toledo","27590000","city","Portão Branco","2","19","2017-08-24
> 11:26:04",1,"empresas"],0.39]
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2itucpU
via IFTTT
Aucun commentaire:
Enregistrer un commentaire