Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

relatable query not applying to belongsto #5743

Closed
jdion84 opened this issue Jul 23, 2023 · 1 comment
Closed

relatable query not applying to belongsto #5743

jdion84 opened this issue Jul 23, 2023 · 1 comment
Labels
needs more info More information is required

Comments

@jdion84
Copy link

jdion84 commented Jul 23, 2023

  • Laravel Version: 10
  • Nova Version: 4
  • PHP Version: 8
  • Database Driver & Version: mysql
  • Operating System and Version: mac
  • Browser type and version: chrome

Description:

i am trying to sort the select dropdown for belongsto relationship

in my Lead resource, i have a belongsto field:

                BelongsTo::make('Status')
                    ->dontReorderAssociatables()

i have tried using the relatable query method to sort the select:

    public static function relatableQuery(NovaRequest $request, $query)
    {
        return $query->orderBy('order');
    }

it does not sort the Status belongsto select by what i am specifying

@crynobone
Copy link
Member

Try the following:

public static function relatableQuery(NovaRequest $request, $query)
{
     return $query->reorder()->orderBy('order');
}

@crynobone crynobone added the needs more info More information is required label Jul 23, 2023
@laravel laravel locked and limited conversation to collaborators Jul 24, 2023
@crynobone crynobone converted this issue into discussion #5744 Jul 24, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
needs more info More information is required
Projects
None yet
Development

No branches or pull requests

2 participants