It could be like this
$tasks = Task::where('company_id', $company_id)->where('created_by',$user_id)->orWhere(function ($query) use ($task_ids) {
$query->where('deleted_at', null)->whereIn('id', $task_ids);
})->get();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have a query
$tasks = Task::where('deleted_at', null)->where('company_id',$company_id);
$tasks = $tasks->where('created_by',$user_id);
$tasks = $tasks->orWhereIn('id',$task_ids);
It generate below query
SELECT * FROM `tasks` WHERE `deleted_at` IS NULL AND `company_id` = 25 AND `created_by` = 20 OR
`id` IN(112,...215) ORDER BY `id` DESC
Now Id 112 is deleted but still showing in result, although i have where('deleted_at', null) condition but it is not working
how to apply that as well?
Please or to participate in this conversation.