“Como usar concat em Laravel” Respostas de código

Concate em Laravel 8


    $users = DB::table('users')->select("*", DB::raw("CONCAT(users.first_name,' ',users.last_name) AS full_name"))
        ->get();
Deepanjalee

Como usar concat em Laravel

public function scopeFindUserByName($query,$name) {
    // Concat the name columns and then apply search query on full name
    $query->where(DB::raw(
            // REPLACE will remove the double white space with single (As defined)
            "REPLACE(
                /* CONCAT will concat the columns with defined separator */
                CONCAT(
                    /* COALESCE operator will handle NUll values as defined value. */
                    COALESCE(name_first,''),' ',
                    COALESCE(name_middle,''),' ',
                    COALESCE(name_last,'')
                ),
            '  ',' ')"
        ),
    'like', '%' . $name . '%');
}
Yellowed Yak

Respostas semelhantes a “Como usar concat em Laravel”

Perguntas semelhantes a “Como usar concat em Laravel”

Mais respostas relacionadas para “Como usar concat em Laravel” em PHP

Procure respostas de código populares por idioma

Procurar outros idiomas de código