0

I have a column like this :

enter image description here

and i've gotten this array

"specification" => array:3 [▼
    0 => "27"
    1 => "26"
    2 => "24"
  ]

how can I compare these two with eloquent like this :

SpecificationItemGroup::where('specification_items', [$request->specification])->get()
3
  • print your query and compare... may be [] is no need in where condition... Commented Aug 9, 2020 at 5:36
  • @hassan try this SpecificationItemGroup::where('specification_items', $request->specification)->get() Commented Aug 9, 2020 at 5:43
  • @wadleo does not work Commented Aug 9, 2020 at 5:45

1 Answer 1

4

Since you're storing it as json encoded string, you should try encoding the array and compare it

SpecificationItemGroup::where('specification_items', json_encode($request->specification))->get()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.