In this tutorial you will learn about the Laravel 8 Eloquent Multiple Where Clause Query Example and its application with practical example.
In this Laravel 8 Eloquent Multiple Where Clause Query Example tutorial, I’ll show you how to use multiple where clause in laravel eloquent query. In this tutorial you will learn to use or apply multiple where clause in laravel query. In this article I will share various example to use multiple where clause with laravel query builder and eloquent model. When you fetch data from database tables you come to situation when you need to pass multiple conditions in laravel query. In laravel eloquent queries this can be done by providing multiple where clause in laravel eloquent query.
Laravel 8 Eloquent Multiple Where Clause Query Example
Below is general syntax of where() condition.
1 |
->where('column_name', 'operator', 'value') |
Multiple Where Condition with Query Builder
In this example we will be using Multiple where conditions in laravel query builder:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
<?php namespace App\Http\Controllers; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\DB; class CountryController extends Controller { public function index() { $words = DB::select('*') ->where('hey', '=', 1) ->where('hello', '=', 1) ->where('hey_there', '=', 1) ->where('hi_there', '=', 1) ->where('you_and_i', '=', 1) ->where('thunder_is_blunder', '=', 1) ->where('when_then', '=', 1) ->where('this_is_me', '=', 1) ->get(); print_r($words); } } |
Laravel Multiple Where Clause with Eloquent Model
In this example we will be using Multiple where conditions in laravel model:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
<?php namespace App\Http\Controllers; use App\Http\Controllers\Controller; use App\Book; class CountryController extends Controller { public function index() { $book = Book::table('students') ->where('hey', '=', 1) ->where('hello', '=', 1) ->where('hey_there', '=', 1) ->where('hi_there', '=', 1) ->where('you_and_i', '=', 1) ->where('thunder_is_blunder', '=', 1) ->where('when_then', '=', 1) ->where('this_is_me', '=', 1) ->get(); print_r($book); } } |