Answers.Body: <p>Totally untested but this should work</p>
  
  <pre><code>$enabledSiteIds = (new Query())
      -&gt;select('siteId')
      -&gt;from('{{%elements_sites}}')
      -&gt;where([
          'enabled' =&gt; true,
          'elementId' =&gt; $elementId
      ])
      -&gt;column();
  </code></pre>
  
  <p>You might want to join the <code>elements</code> and <code>entries</code> table in order to gain only elements where <code>elements.enabled</code> is true too (and check the expiry date), otherwise you'll receive disabled entries</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-06T05:28:44.787Z
Answers.LastActivityDate: 2018-06-06T05:28:44.787Z
Answers.UserDisplayName: Robin Schambach
Answers.Body: <p><code>$entry-&gt;getLocalized()-&gt;all()</code> will return an array of the same entry in other locales.  You could map that into a list of all of the site's handles:</p>
  <pre class="lang-php prettyprint-override"><code>array_map(function($entry)  {
    return $entry-&gt;site-&gt;handle;
  }, $entry-&gt;getLocalized()-&gt;all())
  </code></pre>
  <p><a href="https://docs.craftcms.com/api/v3/craft-base-element.html#public-methods" rel="nofollow noreferrer">Docs</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-23T23:07:50.427Z
Answers.LastActivityDate: 2022-05-23T23:07:50.427Z
Answers.UserDisplayName: weotch
Body: <p>I'm looking for a way to list all the enabled sites for a given entry. 
   I couldn't find some sort of <code>getEnabledSites</code> method that's similar to the available <a href="https://docs.craftcms.com/api/v3/craft-elements-entry.html#method-getsupportedsites" rel="nofollow noreferrer"><code>getSupportedSites</code></a>.  The latter only returns the <code>siteId</code> and <code>enabledByDefault</code> properties.</p>
  
  <p>Note that I'm doing this within the <a href="https://github.com/craftcms/element-api" rel="nofollow noreferrer">Element API</a> plugin.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-06T05:02:48.590Z
Comments.Text: Do you want to get all available sites for the element or all sites where `enabledForSite` is true?
Comments.UserDisplayName: Robin Schambach
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-06T05:15:54.973Z
Comments.Text: @RobinSchambach I want the latter, i.e. "all sites where enabledForSite is true".  The available sites can be retrieved using the getSupportedSites method.
Comments.UserDisplayName: biko
Tags: <entries><craft3><plugin-elementapi><multi-site>
Title: Craft 3: get enabled sites of an entry
ThreadText: # Craft 3: get enabled sites of an entry
  
  (Asked by: username_0 on 2018-06-06)
  
  I'm looking for a way to list all the enabled sites for a given entry.
  I couldn't find some sort of `getEnabledSites` method that's similar to the available [`getSupportedSites`](https://docs.craftcms.com/api/v3/craft-elements-entry.html#method-getsupportedsites). The latter only returns the `siteId` and `enabledByDefault` properties.
  
  Note that I'm doing this within the [Element API](https://github.com/craftcms/element-api) plugin.
  
  **Tags:** entries, craft3, plugin-elementapi, multi-site
  
  > **Comments:**
  > **username_1**: Do you want to get all available sites for the element or all sites where `enabledForSite` is true?  
  > **username_0**: @username_1 I want the latter, i.e. "all sites where enabledForSite is true".  The available sites can be retrieved using the getSupportedSites method.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-06-06. Score: 3 | Accepted answer
  
  Totally untested but this should work
  
  ```
  $enabledSiteIds = (new Query())
      ->select('siteId')
      ->from('{{%elements_sites}}')
      ->where([
          'enabled' => true,
          'elementId' => $elementId
      ])
      ->column();
  
  ```
  
  You might want to join the `elements` and `entries` table in order to gain only elements where `elements.enabled` is true too (and check the expiry date), otherwise you'll receive disabled entries
  
  
  ---
  
  ### Answer by username_2 on 2022-05-23. Score: 1
  
  `$entry->getLocalized()->all()` will return an array of the same entry in other locales. You could map that into a list of all of the site's handles:
  
  ```php
  array_map(function($entry)  {
    return $entry->site->handle;
  }, $entry->getLocalized()->all())
  
  ```
  
  [Docs](https://docs.craftcms.com/api/v3/craft-base-element.html#public-methods)
  
  
  ---
  
  