title: Laravel Eloquent Select CASE?
body: <p>Is there anyone with experience in PHP &amp; Laravel Eloquent who can help me resolve this statement? I'm trying to inject a CASE... WHEN.. END... inside a raw() method. It seemed like it was completely ignored. The existing documentation hasn't been . I've tried several different things to no prevail. I'm trying to pull this off:</p>
  
  <pre><code>SELECT shares.id, ..., 
     CASE WHEN users.id = &lt;CurrentUser&gt; THEN 1 ELSE 0 END AS is_user, 
     ...
  FROM &lt;table&gt;
  ...
  </code></pre>
  
  <p>The source code is below:</p>
  
  <pre><code>$shares = Share::where('shares.status', '=', SHARE_STATUS_APPROVED)
                      -&gt;where('shares.deleted', '=', '0')
                      -&gt;where('locations.lat', '&lt;=', $nelat)
                      -&gt;where('locations.lat', '&gt;=', $swlat)
                      -&gt;where('locations.lng', '&gt;=', $nelng)
                      -&gt;where('locations.lng', '&lt;=',  $swlng)
                      -&gt;where('users.id', '=',  $user)
                      -&gt;orWhere('shares.connected_user_id', '=',  $user)
                      -&gt;join('users', 'shares.user_id', '=', 'users.id')
                      -&gt;join('locations', 'locations.id', '=', 'users.location_id')
                      -&gt;join('provinces', 'provinces.id', '=', 'locations.province_id')
                      -&gt;join('countries', 'countries.id', '=', 'locations.country_id')
                      -&gt;select('shares.id AS share_id', 'users.id AS user_id', 'shares.connected_user_id', 'shares.original_language_id', 'shares.image',
                          'users.first_name', 'users.last_name', 'users.email',
                          'locations.city', 'provinces.name', 'countries.code',
                          'locations.lat', 'locations.lng',
                          'shares.created_at')
                      -&gt;raw('(CASE WHEN users.id = ' . $user . ' THEN 1 ELSE 0 END) AS is_user')
                      -&gt;orderBy('shares.created_at', 'desc')
                      -&gt;orderBy('users.id', 'asc')
                      -&gt;orderBy('shares.connected_user_id', 'asc')
                      -&gt;get();
  </code></pre>