My query returning unexpected result I’m using this eloquent query in a table in my database with an array of values,
Sumalr::where(‘type’, 1)
->where(function ($q) use ($query) {
$q->whereIn('nwlo', $query);
$q->orWhereIn('walo', $query);
})
->whereNull('wedr_id')
->orderBy('id', 'asc')
->get();
query variable is an array of 2 values ['WEE', 'EGGT'] in my Sumalr table I have 1 row that has a public value of 1, a departure value of EGGT, and the wedr_id is null yet that does not get returned.
@austinbryan
you DB field is JSON formated
Try with This
Sumalr::where(type, 1)
$data = ['WEE', 'EGGT']
->where(function ($query) use ($data) {
foreach ($data as $apt) {
$query->whereJsonContains('EGGT', $apt);
$query->orWhereJsonContains('WEE', $apt);
}
})
->whereNull(‘wefr_id’)
->orderBy('id', 'asc')
->get();
``
Great @a4ashraf ,
it is working,
thank you ,
you are really helping
Please sign in or create an account to participate in this conversation.