where clause in laravel code answer – 2024

In this article, we will learn about how to use where clause in laravel.

1). laravel not in query

DB::table(..)->select(..)->whereNotIn('book_price', [100,200])->get();

2). wherein laravel

 DB::table('user')->whereIn('id', [100,200])->get();

3). laravel db::query update

Source: stackoverflow.com

DB::table('user')->where('email', $userEmail)->update(array('member_type' => $plan));

4). laravel wher in

$users = DB::table('users')
                    ->whereIn('id', [1, 2, 3])

5). laravel with and where

$projects = Project::whereHas('projectOffers', function ($offer) {
            $offer->where('teacher_id', "Ahmed");
            $offer->where('status_id', "Accepted");
        })->where('status_id', "inprogress")->get();

6). where clause in laravel

 $users = DB::table('user')->select('id', 'name', 'email','api_token','created_at')->where('email' , $email)->get();
        return response()->json($users);

Discover more from STRUGGLER KING.COM

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

Continue Reading