This snippet returns TRUE or FALSE if an entity has a filled-in value on a entity reference on field_winner field.

A nice example of the Exists condition on entityQuery

   * Returns true if there is already a winner of one active contest.
   * @return FALSE|TRUE
  public function contestHasWinner()
    // Find a winner of at least one active contest
    $count = \Drupal::entityQuery('contest')
      ->condition('status', 1)
    return ($count > 0) ? TRUE : FALSE;




Saved you some valuable time?

Received 100 so far from 4 kind contributors.