I want to query Laravel DB for something like
SELECT * FROM `tickets`
WHERE (created_at > '2015-07-01'
AND created_at < '2015-07-31')
AND (state != 'Resolved'
OR state != 'closed'
OR state != 'Cancelled'
OR state != 'Solution Rejected')
ORDER BY `id` DESC
I tried using raw statements but doesn't seem to work. So I'm trying to use Laravel's own model functions to archive the same result, but I'm missing something... here's what I got so far.
Ticket::whereBetween('created_at', [$start, $end])
->whereIn('state',['Resolved','closed','Cancelled','Solution Rejected'])
->get();
PS: alternatively is there a way I can have this instead
SELECT * FROM `tickets`
WHERE ( (created_at > '2015-07-01'
AND created_at < '2015-07-31')
OR (updated_at > '2015-07-01'
AND updated_at < '2015-07-31') )
AND (state != 'Resolved'
OR state != 'closed'
OR state != 'Cancelled'
OR state != 'Solution Rejected')
ORDER BY `id` DESC
state != 'Resolved' OR state != 'closed' ...will always be true becuasestatecan't have multiple values at the same time