function getCategoryExperts($id) { if (isset($id)) { $experts = Expert::whereIn('id', function ($query) use($id) { $query->select('expert_id')->from('expert_categories')->where('category_id', $id)->where('status', 'active'); })->get(); if (isset($experts) && count($experts) > 0) { return json_encode(array('message' => 'found', 'experts' => $experts->toArray())); } else { return json_encode(array('message' => 'empty')); } } else { return json_encode(array('message' => 'invalid')); } }