Skip to content
Advertisement

Laravel filter relationship data

Code

JavaScript

Data return

JavaScript

Question: I tried to filtering data that if a relationship “getCauserDetails”, How can I not show the data if the relationship name is only found “test” or should I say null? So on the example output, it displays all the data, but I want to only the data that I filter just retrieve.

Advertisement

Answer

Because of your orWhere() you need to nest it:

JavaScript

You can filter the relation, too:

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