--level used:17 Call to an undefined method
Illuminate\Support\Collection::makeHidden().
The doc-tag of \Illuminate\Database\Eloquent\Collection::map() says @return \Illuminate\Support\Collection|static - so it warns me for the case that the map() returns a base collection?
UserSession::with('user')->get()->map(function (UserSession $userSession) {
$userSession->setAttribute('user_email', $userSession->user->email);
$userSession->setAttribute('user_name', $userSession->user->full_name);
return $userSession;
})->makeHidden('user')
Where is makeHidden defined? Is it a custom Collection macro?
No, it's a default Laravel eloquent collection method.
https://laravel.com/docs/5.8/eloquent-serialization#hiding-attributes-from-json
Ah, sorry my bad. So it thinks it returns Illuminate\Support\Collection not Illuminate\Database\Eloquent\Collection
I made a fix for the return type of get. I'll open the PR today. Then we'll see :+1:
While https://github.com/laravel/framework/pull/30239 got merged into 6.3 I am seeing the same with a get() call on Eloquent queries. Testing a few things out this hopefully gets resolved with https://github.com/nunomaduro/larastan/pull/325 as it only happens when using where statements.
Can you test this with the latest changes in master branch?
I am no longer seeing the issue with dev-master.
Thanks @spaceemotion ! Good job @canvural
Most helpful comment
Ah, sorry my bad. So it thinks it returns
Illuminate\Support\CollectionnotIlluminate\Database\Eloquent\CollectionI made a fix for the return type of
get. I'll open the PR today. Then we'll see :+1: