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

server-side search on relationships #5645

Open
toto975 opened this issue Aug 5, 2022 · 2 comments · May be fixed by #5754
Open

server-side search on relationships #5645

toto975 opened this issue Aug 5, 2022 · 2 comments · May be fixed by #5754

Comments

@toto975
Copy link
Contributor

toto975 commented Aug 5, 2022

Laravel version

9.7.0

PHP version

8.1.4

Voyager version

1.5

Database

MySQL 8.0.28

Description

Search on relationship with serverside pagination

Steps to reproduce

Model Parcours (id, cadre_id, date)
Model Cadre (id, name)
In the BREAD, Parcours has relationship belongsTo Cadre and display Cadre name

In the Parcours list view, the column Cadre is sortable.
But the search field goes to this error :

SQLSTATE[42S22]: Column not found: 1054 Field 'parcours.parcour_belongsto_cadre_relationship' unknown in where clause
select count(*) as aggregate from `parcours` left join `cadres` as `joined` on `parcours`.`cadre_id` = `joined`.`id` where `parcours`.`parcour_belongsto_cadre_relationship` LIKE %NAME% and `parcours`.`deleted_at` is null

Expected behavior

The SQL Query must be

select count(*) as aggregate from parcoursleft joincadresasjoinedonparcours.cadre_id=joined.idwherecadre.nameLIKE %NAME% andparcours.deleted_at is null

Screenshots

None of theses fixes work for me :
#5635
#5449
#5412
#5312
#5245
#5185
#3595

I put same name for cadre_id and Cadre relationship.
I check the cadre_id browse.
I uncheck the Cadre browse
image
The search is OK.
But it's the cadre_id which is displayed.
image
I want the cadre'name

Next I check the Cadre browse
image
The search is OK, it's the Cadre name which is displayed.

But there is both Cadre in the select dropdown search field, one for cadre_id, the other for Cadre relationship
image

Additional context

No response

@samiksengupta samiksengupta linked a pull request Apr 3, 2023 that will close this issue
@Walt2018
Copy link

to avoid duplication in the fields

DO in file bread browse.blade.php

@if ($key !== 'replacehere_belongsto_replacehere_relationship')
<option value="{{ $key }}"
@if ($search->key == $key || (empty($search->key) && $key == $defaultSearchKey)) selected @endif>
{{ $name }}
@endif

@vikasfreedom
Copy link

Did anyone find exact solution to this ? @Walt2018 your code will only work for specific browse file, what happens if it is showing in all the filters wherever we created a relationships in BREAD ? we can't make custom browse files for each module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants