Reputation: 2893
I am trying to figure out why something is happening.
When a Model is created it is given a status parameter. Initially the status is Awaiting Information, but it soon gets changed to Awaiting Acceptance. I am trying to display models on my page only if their status has passed these two stages. At the moment I have the following
$projects = Project::with('client')->where('status', '!=', 'Awaiting Information')->orWhere('status', '!=', 'Awaiting Acceptance')->get();
For some reason however, this returns a project that has the status Awaiting Information. If I remove the orWhere part, then no projects are displayed as is expected. It appears the orWhere is throwing the query off. I am looking to return all projects which do not have these statuses.
Am I missing something here in my clauses?
Thanks
Upvotes: 0
Views: 65
Reputation: 7504
I would suggest you to use whereNotIn method for your query:
$projects = Project::with('client')->whereNotIn('status', ['Awaiting Information', 'Awaiting Acceptance'])->get();
Upvotes: 1