📜  sql 查询 laravel 中的用例条件 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:23.549000             🧑  作者: Mango

代码示例1
->selectRaw("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,
      (CASE WHEN users.id = {$user} THEN 1 ELSE 0 END) AS is_user)")
    ->orderBy('shares.created_at', 'desc')