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

BelongsToMany filterable() - Not working on detail page #5605

Closed
TNDJX opened this issue Jun 9, 2023 · 3 comments
Closed

BelongsToMany filterable() - Not working on detail page #5605

TNDJX opened this issue Jun 9, 2023 · 3 comments
Assignees
Labels
bug Verified bug by the Nova team

Comments

@TNDJX
Copy link

TNDJX commented Jun 9, 2023

  • Laravel Version: 9.48.0
  • Nova Version: 4.21.0
  • PHP Version: 8.1

Description:

BelongsToMany filterable() method is not working correctly on the detail page.
Looking at the logged queries they don't make any sense when filtering on the detail page

Screen.Recording.2023-06-09.at.12.49.11.mov

Detailed steps to reproduce the issue on a fresh Nova installation:

To reproduce this issue you will need to have 3 resources here is an example of connections and setup

User:

User Model
public function bookings(): HasMany
  {
      return $this->hasMany(Booking::class);
  }

User resource
HasMany::make(__('Bookings'), 'bookings', Booking::class),

Booking:

Booking Model
    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }

    public function tables(): BelongsToMany
    {
        return $this->belongsToMany(Table::class);
    }

Booking Resource
   BelongsTo::make(__('User'), 'user', User::class),

  BelongsToMany::make(__('Tables'), 'tables', Table::class)
                ->filterable(),

Table

Table Model
    public function bookings(): BelongsToMany
    {
        return $this->belongsToMany(Booking::class);
    }
@crynobone
Copy link
Member

Please provide full reproducing repository based on fresh installation as suggested in the bug report template (or you can refer to https://github.com/nova-issues for example)

@crynobone crynobone added the needs more info More information is required label Jun 9, 2023
@TNDJX
Copy link
Author

TNDJX commented Jun 9, 2023

@crynobone Here is a reproducing repository

https://github.com/TNDJX/nova-issue-5605

I have added a database seeder as well so you can run migrate and seed and should be good to go.

You will notice that when going on the Bookings resource and use the Tables filter you will get correct results

But when going on Users resource and scroll down to Bookings relation if you apply Tables filter either no results or wrong results will be shown

@crynobone crynobone added bug Verified bug by the Nova team and removed needs more info More information is required labels Jun 12, 2023
@crynobone crynobone self-assigned this Jun 12, 2023
@github-actions
Copy link

github-actions bot commented Jul 2, 2023

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Verified bug by the Nova team
Projects
None yet
Development

No branches or pull requests

2 participants