Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

nuna's avatar
Level 1

Payment::PROCESS only returns value for where payment_status = 0.How to make this query return result for where condition where payment status = 0,1

$filter->where(function ($query) {

            switch ($this->input) {
                case Payment::PROCESS:
                    $query->where('payment_status', '=',[0,1]);
                    break;
                case Payment::PENDING:
                    $query->where('payment_status' , Payment::PENDING);
                    break;
                case Payment::SUCCESS:
                    $query->where('payment_status' , Payment::SUCCESS);
                    break;
                case Payment::FAILED:
                    $query->where('payment_status' , Payment::FAILED);
                    break;
                case Payment::CANCELLED:
                    $query->where('payment_status' , Payment::CANCELLED);
                    break;
                case Payment::PENDING_AUTH:
                    $query->where('payment_status' , Payment::PENDING_AUTH);
                    break;
            }
        }, 'Payment Status', 'status')->select([
                    Payment::PROCESS => 'Pending',
                    Payment::SUCCESS => 'Success',
                    Payment::FAILED => 'Failed',
                    Payment::CANCELLED => 'Cancelled',
                    Payment::PENDING_AUTH => 'Pending Auth (B2B)',
           
        ]);
    });
0 likes
3 replies
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

Use whereIn

                    $query->whereIn('payment_status', [0,1]);
1 like
nuna's avatar
Level 1

Wow..thanks..it works really well.

Snapey's avatar

@nuna what's the point of having CONST values and then not using them?

Please or to participate in this conversation.