man-u-l
2 months ago
757
6
Laravel

Fluent Strings Str::of() Returns Illuminate\Support\Stringable and not result

Posted 2 months ago by man-u-l

I did some test but rather than getting text back from this:

$slice = Str::of('This is my name')->after('This is'); 

I get back:

Illuminate\Support\Stringable 

And when I try to return its value in a JSON response $slice is empty

In my controller I have

use Illuminate\Support\Str;

$slice = Str::of('This is my name')->after('This is'); 

return response()->json([
            'data'       => ['text' => $slice]
        ], 200);

But the JSON response data is empty.

Any pointers will be greatly appreciated

Please sign in or create an account to participate in this conversation.