Skip to content
Advertisement

Laravel orWherehas filtering relationship with multiple columns

I’m facing a problem with search filtering, Project is with Laravel, Inertia js, Vue js

I want to show all invoices with Recipient Information on it which has a foreign key on it to make this possible, also I have relationships on my model Data on Front-end end are showing successfully but when I try to filter it show’s me an error Details:…

there are two tables:

Recipients:

id (PRIMARY KEY) Auto Increment, foreign key

name

customer_number

…/(not necessary)

Invoices:

invoice_nr (PRIMARY KEY) Auto Increment

recipient_id -> foreign key {with id of recipients}

i also have relationships on my models :

Invoices.php Model

JavaScript

Recipients.php Model

JavaScript

data came on front-end it’s all good, but when I try to search filtering, on that time its shows me this error: enter image description here

here is my Invoices Controller code function show_Invoices

JavaScript

data from backend came on invoices object successfully, but when I try to search it doesn’t work

in Frontend .. .vue script here it is

JavaScript

Advertisement

Answer

with a bit of help from John Lobo, and by myself I found solutions for my problem.

Tip: This is a Solution if you want to filter multiple columns of relationship and parent table also, in laravel, it’s a bit nested but it makes a solution if you had the same problem with me.

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement