It may be a simple thing, but cant figure it out without making more complicated if/else statement which I believe is not needed.
I need to retrieve name of user with specified id number. But there is a chance, that user with given id doesnt exist.
With such code:
$author = User::select('name')->where('id', $givenId)->firstOr( function () { return 'Gone'; });
and it works almost fine, but if user exists, Im getting an array {"name":"User"} as a result. Cant just write ->value('name') at the end cause when user doesnt exists it gives me an error that I run method value on a null object.