0

I have these two variables

$categories = Relation::select('child_id', 'distance')
->where('parent_id', $request->who)
->orderBy('distance', 'asc')
->get();

$request->newParent; 

Is there any way to check if my query result($categories) contains id same as $request->newParent without making another database query.

1 Answer 1

1

Try this

$categories = Relation::with('newParent')
 ->select('parent_id','child_id', 'distance')->where('parent_id', 
$request->newParent)->orderBy('distance', 'asc')->get();

return $categories; 
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.