Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

whenLoaded vs whenCounted #711

Closed
1 task done
thewhaleiam opened this issue Aug 17, 2023 · 3 comments
Closed
1 task done

whenLoaded vs whenCounted #711

thewhaleiam opened this issue Aug 17, 2023 · 3 comments
Labels

Comments

@thewhaleiam
Copy link

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
Copy link
Contributor

shalvah commented Aug 17, 2023

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 shalvah removed the triage label Aug 17, 2023
@shalvah
Copy link
Contributor

shalvah commented Aug 19, 2023

Ah, I think this is another person with the same issue: #620

@shalvah
Copy link
Contributor

shalvah commented Aug 19, 2023

Gonna close this one in favour of that.

@shalvah shalvah closed this as completed Aug 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants