thedevdojo / voyager

Voyager - The Missing Laravel Admin
https://voyager.devdojo.com
MIT License
11.72k stars 2.67k forks source link

Relationship doesn't join by properly when searching in BREAD #5738

Open AdelinGhanaem opened 1 year ago

AdelinGhanaem commented 1 year ago

Laravel version

8.83.27

PHP version

7.3|^8.0

Voyager version

^1.6

Database

MySQL 8

Description

I have two entities CarMake and CarModel

CarModel belongs to CarMake join table

create table car_makes
 (
    id             bigint unsigned auto_increment primary key,
    created_at     timestamp               null,
    updated_at     timestamp               null,
    make           varchar(255) default '' not null,
    make_ar        varchar(255) default '' not null,
    make_en        varchar(255) default '' not null,
    logo_url       varchar(255) default '' not null,
    description_ar varchar(255) default '' not null,
    description_en varchar(255) default '' not null
)
create table car_models
(
    id     bigint unsigned auto_increment    primary key,
    created_at timestamp               null,
    updated_at timestamp               null,
    model      varchar(255)            not null,
    model_en   varchar(255) default '' not null,
    model_ar   varchar(255) default '' not null,
    make_id    bigint unsigned         not null,
    constraint car_models_make_id_foreign
        foreign key (make_id) references car_makes (id)
)

Now, I created two BREADs in the admin panel, when I try to search models by make and I get an error. I checked the query to see why this is happening and I get a very strange query

image

Well there is no column called car_model_belongsto_car_make_relashionship

Steps to reproduce

Expected behavior

It should join by the foreign key column and search the particular column that is in the relationship.

Screenshots

Screenshot 2023-02-21 at 21 44 18

Screenshot 2023-02-21 at 21 44 36

Screenshot 2023-02-21 at 21 45 17

image

Additional context

No response