Example in doc:
DB::table(\'users\') ->whereExists(function($query) { $query->select(DB::raw(1)) ->fro
If you are using Laravel eloquent you may try this as well.
$result = self::select('*') ->with('user') ->where('subscriptionPlan', function($query) use($activated){ $query->where('activated', '=', $roleId); }) ->get();