Reputation: 25
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.
Upvotes: 0
Views: 437
Reputation: 706
Try this
$categories = Relation::with('newParent')
->select('parent_id','child_id', 'distance')->where('parent_id',
$request->newParent)->orderBy('distance', 'asc')->get();
return $categories;
Upvotes: 1