I got a params which is projectname and it accepts any string based on the column of my db. What I want is when I search a keyword which is like this BEDOK, then shows me the concatinated list of the columns in my db. Like this BEDOK-20,BEDOK-22.
My controller code i tried
public function getNames(Request $request){
$result = DB::connection('mysql2')
->table('xp_pn_resale')
->select('town')
->whereRaw(DB::raw("CONCAT(town, ' ', street_name,'',block,'')LIKE '%$request->projectname%' "))
->limit($request->limit)
->get();
// ->toSql();
return response()->json($result);
}
And i got response like this
"town": "BEDOK"
},
{
"town": "BEDOK"
},
{
"town": "BEDOK"
},
...
What I want is like this
[
"town": "BEDOK-44"
},
{
"town": "BEDOK-540"
},
{
"town": "BEDOK-702"
},
...
