0

I have a table called services with multiple columns and one column named staff_assigned with this content:

[{"user_id":"15549","price":"100"},{"user_id":"15548","price":"300"},{"user_id":"15552","price":"95"},{"user_id":"15553","price":"600"}]

How can I find all services where user_id is 15548 with Laravel eloquent?
Note that

Service::where('staff_assign->user_id', "15548")->get();

doesn't work because column contains array of objects.

Thank you!

2 Answers 2

1

Maybe you can try this:

->whereJsonContains('staff_assign',  ['user_id' => '15548'])
Sign up to request clarification or add additional context in comments.

Comments

0

Service::where('user_id', '=' , "15552")->get();

Just add the '=';

1 Comment

user_id is not column. staff_assign is column with array of objects.

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.