Laravel concat不工作

时间:2017-05-23 09:21:17

标签: php laravel laravel-5 laravel-eloquent laravel-orm

我在Laravel CONCAT上遇到了一个问题,它没有连接数据库字段。当我检查返回的数据时,它没有 fullName

public function getAllPlayers()
{
    $data = Player::select(DB::raw('CONCAT(familyName," ",firstName) AS fullName'))
        ->orderBy('familyName', 'asc')
        ->join('teams', 'players.primaryClubId', '=', 'teams.clubId')
        ->select(['players.*', 'teams.teamName', 'teams.teamNickname', 'teams.teamCode'])
        ->get()
        ->unique() //remove duplicates
        ->groupBy(function($item, $key) { //group familyName that starts in same letter
            return substr($item['familyName'], 0, 1);
        })
        ->map(function ($subCollection) {
            return $subCollection->chunk(4); // put your group size
        });

    return $data;
}

1 个答案:

答案 0 :(得分:1)

您正在使用其他hadoop distcp hdfs://localhost:8020/LEARN hdfs://cloudera.hadoop:8020/Test覆盖select。要添加多个选择,您需要使用select方法。

addSelect