Sunday, March 19, 2017

Laravel map to return single value shows as object, not as string

Within my view, I am displaying a value but it's showing as an object: ["Thomas Hill"]. I want to remove the [" ... "]part.

Function:

$auditor = $audit->map(function ($user) {
    return $user->name;
});

If I cast the value, using return (string) $user->name, it doesn't change it.



via Ben

Advertisement