@CMDOBUENO - thank you for the clarity, so it seems to be working as far as CONCAT, however the data returned is only the name object which is created by the CONCAT.
So if I do a search for John It simply returns whatever name matches instead of the entire record like so
{
name: 'John Smith'
}
Where as it should return the record for John Smith like
{
first_name: 'John'
last_name: 'Smith'
engagements: [
{ engagement: 1},
{ engagement: 1},
{ engagement: 1},
]
}
Here is the set up
public function search(Request $request)
{
$client = $request->validate([
'keyword' => 'required|string'
]);
$results = Client::query()
->select(\DB::raw("CONCAT(first_name,' ',last_name) AS name") )
->havingRaw( " name LIKE '%$request->keyword%'")
->with('engagements')
->get();
return response()->json($results);
}
note* this also happens if I do the more complex search of John Smith. It still only returns the name object.
I am not sure if I mentioned that I am doing this through ajax if that makes a difference? again thank you for the help!