Home > Back-end >  How to select the column who has this Client name in laravel9
How to select the column who has this Client name in laravel9

Time:08-25

 public function clientname()
    {
        $client = Commande::Where('client_name' , '=' , '')->get();
        return response()->json($client);
    };

I want to select the column who has this Client name, but doesn't work -- they give an empty array instead.

CodePudding user response:

use this function

 public function clientname()
 {
    $client = Commande::whereColumn('client_name' , 'client_name')->get();
    return response()->json($client);
 };

CodePudding user response:

Firstly there is no need of using an '=' as it will automatically check, and also if you want to check if first value match the other one , it will use '==' not '=' as = is use to assign the values Secondly, For your answer try using this

public function clientname()
    {
        $client = Commande::where('client_name', '')->get();
        return response()->json($client);
    };
  • Related