Skip to content

Laravel Debugbar show duplicate queries #1

@tommy66374

Description

@tommy66374

Laravel Debugbar show duplicate queries

In the CanPaginateViewRecord trait, $this->getPreviousRecord() and $this->getNextRecord() fired two times

may be store as a variable in the if statement to reduce the method fired again.

    protected function configurePreviousAction(Action $action): void
    {
        // Here store as a variable the previous record
        if ($previousRecord = $this->getPreviousRecord()) {
            $action->url(fn (): string => static::getResource()::getUrl(static::getResourcePageName(), ['record' => $previousRecord]));
        } else {
            $action
                ->disabled()
                ->color('gray');
        }
    }

    protected function configureNextAction(Action $action): void
    {
        // Here store as a variable the next record
        if ($nextRecord = $this->getNextRecord()) {
            $action->url(fn (): string => static::getResource()::getUrl(static::getResourcePageName(), ['record' => $nextRecord]));
        } else {
            $action
                ->disabled()
                ->color('gray');
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions