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

How do I get count()? #5

Open
atach opened this issue Aug 18, 2021 · 0 comments
Open

How do I get count()? #5

atach opened this issue Aug 18, 2021 · 0 comments

Comments

@atach
Copy link

atach commented Aug 18, 2021

I am trying to get the total count() before I apply get(), but it gives an error.

$returnData = $this->trainerSlot
            ->orderBy('date')
            ->orderBy('place_id')
            ->offset(0)->limit(25);
        $allCount = $returnData->count(); // Error

If I use the same construction without a repository it works.

$returnData = TrainerSlot::orderBy('date')
            ->orderBy('place_id')
            ->offset(0)->limit(25);
$allCount = $returnData->count(); // find total 1200 string

If I try to get the total amount after, I called $returnData->get(), then it only gives out the amount received after the limit&offset.

$returnData = $this->trainerSlot
            ->orderBy('date')
            ->orderBy('place_id')
            ->offset(0)->limit(25);
$returnData->get();
$allCount = $returnData->count(); // find total 25 string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant