Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

200
Views
How to use condition with query builder

I have orders table which contains status, paymode, pay_status column

I want to get order if paymode is cod then pay_status unconfirmed can get
and
if paymode is payu then pay_status only confirmed can get

Here I tried with whereRaw

$orders = Order::whereHas('products', function (Builder $query) use ($seller) {
            $query->where('seller_id', $seller->id);
        })
            ->whereRaw('IF (`paymode` = `payu`, `pay_status` = `confirmed`)')
            ->paginate(25);

but it's not working

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

you can try like this also for multiple conditions

 $orders = Order::whereHas('products', 
    function (Builder $query) use ($seller) { 
         $query->where('seller_id', $seller->id); 
    })->whereRaw('paymode = ? AND pay_status = ?', ['payu','confirmed']) 
      ->orWhereRaw('paymode = ? AND pay_status = ?', ['cod','unconfimed ']) 
    ->paginate(25); 
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!