public function checkIsOwner(User $user, Entity $entity) { if ($user->id === $entity->get('assignedUserId')) { return true; } if ($user->id === $entity->get('createdById')) { return true; } if ($entity->hasLinkMultipleId('assignedUsers', $user->id)) { return true; } return false; }
public function checkIsOwner(User $user, Entity $entity) { if ($entity->hasAttribute('assignedUserId')) { if ($entity->has('assignedUserId')) { if ($user->id === $entity->get('assignedUserId')) { return true; } } } else { if ($entity->hasAttribute('createdById')) { if ($entity->has('createdById')) { if ($user->id === $entity->get('createdById')) { return true; } } } } if ($entity->hasAttribute('assignedUsersIds') && $entity->hasRelation('assignedUsers')) { if ($entity->hasLinkMultipleId('assignedUsers', $user->id)) { return true; } } return false; }