#5645·voyager

server-side search on relationships

Author: toto975Created Aug 5, 2022Updated Oct 21, 2024
Labelspossible bug

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 : https://github.com/the-control-group/voyager/issues/5635 https://github.com/the-control-group/voyager/issues/5449 https://github.com/the-control-group/voyager/issues/5412 https://github.com/the-control-group/voyager/pull/5312 https://github.com/the-control-group/voyager/pull/5245 https://github.com/the-control-group/voyager/pull/5185 https://github.com/the-control-group/voyager/issues/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