In my Laravel project I'm building a query with some conditionals. There is one issue that I can't get my head around
I have a Query that goes as follows
$query = SocialMediaFeed::where('location_id', $location_id);
Now there are some feed items which have 'self' = true.. These should be ignored from the results at first, unless when there is a $filters array.
if(!$filters) {
$query = $query->where('self', '<>', true);
}
Now I'm wondering, If there are filters, it should include the data that I got when self not equal to true, but also the data if it is true..
I tried the following, But that only returns the self=true posts, instead of all posts combined with self=true
$query = $query
->where('self', '<>', true)
->where('self', true)
->orWhereNull('self');
selfcolumn should be ignored? Then you don't need any filters on theselfcolumn. Could you give some examples for your question?