knuckleswtf / scribe

Generate API documentation for humans from your Laravel codebase.✍
https://scribe.knuckles.wtf/laravel/
MIT License
1.59k stars 280 forks source link

whenLoaded vs whenCounted #711

Closed thewhaleiam closed 10 months ago

thewhaleiam commented 10 months ago

Scribe version

4.8

Your question

At present I send a state to a factory to generate the recommendations. On the Resource when I attempt to generate a count on recommendations nothing is generated in the example output.

'value' => $this->whenCounted('recommendations', fn () => $this->recommendations_count), However using the whenLoaded method generates the recommendation on the resource.

'value' => $this->whenLoaded('recommendations', fn () => $this->recommendations->count()), Is whenCounted not supported by Scribe?

Docs

shalvah commented 10 months ago

You need to understand that the people that maintain this (me) are devs just like you.😅 Laravel has many features; very hard for one person to know them all (and I rarely work with Laravel these days). I'd never even heard of that whenCounted method before now.

I'd ask you to dig into the Scribe source code a bit. I recall someone making an issue about whenLoaded some time back, and contributing a patch that led to it working in Scribe, so maybe you can do something similar in Scribe? There's probably a test for it somewhere, that you can use as a starting point.

shalvah commented 10 months ago

Ah, I think this is another person with the same issue: https://github.com/knuckleswtf/scribe/issues/620

shalvah commented 10 months ago

Gonna close this one in favour of that.