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

fix: sql error when selecting All pages #6650

Closed

Conversation

MohamAladham
Copy link

A fix for #6643

@CLAassistant
Copy link

CLAassistant commented Jun 10, 2023

CLA assistant check
All committers have signed the CLA.

->paginate($perPage);
$contacts = $contacts->search($request->input('search') ?? '', $accountId, 'is_starred', 'desc', $sort);

if($perPage == -1){
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend creating separate methods. It might look like this:

Suggested change
if($perPage == -1){
$total = $this->getTotal($contacts, $perPage);
$contacts = $this->getContacts($contacts, $perPage);

Example of the getTotal() implementation:

private function getTotal($contacts, int $perPage): int
{
    if ($perPage === -1) {
        return $contacts->count();
    }

    return $contacts->paginate($perPage);
}

Please add a type hint for the $contacts argument. The getContacts() method might look similar to the above.

Copy link
Member

@asbiin asbiin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See @kniziol comment

@asbiin
Copy link
Member

asbiin commented Mar 16, 2024

This needs more work, and we don't accept more changes in the 4.x branch. Don't hesitate to reopen it on the main branch if that makes sense.

@asbiin asbiin closed this Mar 16, 2024
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

Successfully merging this pull request may close these issues.

None yet

4 participants