I've had some difficulty updating a model where a string passed into where
is being re-cast or converted to some other type.
There's a varchar
column in the database which holds "dates" in the YYYY-MM format. A query on this column is giving unpredictable results using get() or first() seeing as the query is where period = 2019-01
when it should be (and works manually with) where period = "2019-01"
.
I ended up using DB::raw
to force a string, but i'm not satisfied with this and am still a bit perturbed, seeing as i've identified other instances of this which might only be working coincidentally :\
I tried casting to a string or parsing with Carbon directly before the where
and also adding "period" to the $casts
array in the model, without success.
Version is 5.4.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2TABGcy
via IFTTT
Aucun commentaire:
Enregistrer un commentaire