How to use eloquent whereRaw in Laravel code answer – 2024

In this article, we will learn about how to use eloquent whereRaw in laravel

1). eloquent whereRaw

$orders = DB::table('orders')
                ->whereRaw('price > IF(state = "TX", ?, 100)', [200])
                ->get();

#To use in search
$paciente   = $query->whereRaw("(
        LOWER(name)             like '%". strtolower($search) ."%' OR
        LOWER(sku)              like '%". strtolower($search) ."%' OR
        LOWER(codigo)           like '%". strtolower($search) ."%' OR
        LOWER(descricao_curta)  like '%". strtolower($search) ."%'
    )");

One thought on “How to use eloquent whereRaw in Laravel code answer – 2024

  1. Do you mind if I quote a couple of your posts as long as I
    provide credit and sources back to your site?

    My blog is in the exact same area of interest as yours and my users would definitely benefit from a lot of the information you
    provide here. Please let me know if this okay with you.

    Many thanks!

    Here is my web page; webinar

Comments are closed.

Discover more from STRUGGLER KING.COM

Subscribe now to keep reading and get access to the full archive.

Continue Reading