Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Galavant's avatar

Search on result of other query | return collection

I made a searchbar in which the customer wants to search their relations and contacts (the contacts are linked to that company by CONTACTID in both tables)

so if someone provides input, I query via async. However, I can't wrap my head around this.

As soon as someone provides input, I need to search relations table and contacts table - simultaniously. I want to just provide the output of relations table.

so if we find that the userinput matches an entry in the contact table, I want to take that CONTACTID and search in the relations table and return that result

I've been stuck a lot and I've also looked into eloquent relations but I didn't figure that out.

0 likes
1 reply
Galavant's avatar
RELATIONTABLE

    ID
    CONTACTID
    CUSTID
    NAME
    PHONE


CONTACTTABLE

    ID
    CONTACTID
    NAME
    PHONE

Please or to participate in this conversation.