jeudi 13 septembre 2018

Laravel whereJsonContains in Eloquent giving no results

In the last version of Laravel you have an option to check if Json values are cotaining some values. Why doesn't this whereJsonContains works like I expected it to work:

$users = User::whereIsActive(true)
            ->whereJsonContains('options->foobar', 96)
            ->get();

This is what is stored in the options column (for example):

{"foobar":[96,11,271,256],"sheep":[80,111]}

What I want is to get all Users that have the value 96 in the 'foobar' array.

This is the query when I dump it with ->toSql():

select * from "users" where ("options"->'foobar')::jsonb @> ? 

I'm using PostgreSQL.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2NHvLPh
via IFTTT

Aucun commentaire:

Enregistrer un commentaire