- ->orWhere(function ($query2) use ($userId) {
- $query2->where('has_permission_own', '=', 1)
- ->where('created_by', '=', $userId);
- });
- })
- ->get()->count() > 0;
+ ->orWhere(function ($query2) use ($userId) {
+ $query2->where('has_permission_own', '=', 1)
+ ->where('created_by', '=', $userId);
+ });
+ });
+
+ if (!is_null($entityClass)) {
+ $entityInstance = app()->make($entityClass);
+ $permissionQuery = $permissionQuery->where('entity_type', '=', $entityInstance->getMorphClass());
+ }