Laravel 5.1: handle joins with same column names

前端 未结 4 1860
傲寒
傲寒 2021-02-04 00:00

I\'m trying to fetch following things from the database:

  • user name
  • user avatar_name
  • user avatar_filetype
  • complete conversation_messages<
4条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-04 00:44

    Meh okay.. i've found a simple solution here

    ->select('users.name as userName', 'conversation_messages.*', 'user_avatars.name as avatarName', 'user_avatars.filetype')
    

    As you can mention I've added the requested "as-Feature" next to the table.columnName

提交回复
热议问题