I have a model named Document, Document has a status field where the possible values are, let's say dummy_data ['done', 'failed', 'sent', ....].
I want to get all documents where status='done' if they are present in DB OR all documents where status='sent' if first condition is false.
I have tried this query but I get documents with both statuses.
$result->documents()->where(function ($query) {
$query->where('status', 'done')
->orWhere('status', 'sent');
})->get();
done. Then if there are no results, run another query forsent