1// Get all rows from Eloquent model
2Model::get();
3 //Get all the cars
4 $cars = App\Models\Cars::get();
5
6// Get all rows from Eloquent model where column matches the given value
7Model::where('column', {value})->get();
8 //Get all the blue cars
9 $blue_cars = App\Models\Cars::where('color', 'blue')->get();
10 //Get all the green cars
11 $looking_for = 'green';
12 $green_cars = App\Models\Cars::where('color', $looking_for)->get();
13
14// Get all rows from Eloquent model where column is matched conditionally
15Model::where('column', {condition}, {value})->get();
16 //Get all the antique cars
17 $antiques = App\Models\Cars::where('year', '<=', 2000)->get();
18
19// Get all rows from Eloquent model with multiple where conditions
20 //Get all the green antique cars
21 $green_antiques = App\Models\Cars::where(
22 [
23 ['color', 'green'],
24 ['year', '<=', 2000],
25 ]
26 )->get();
27
28// For very large data sets use cursor() rather than get();
29Model::where('column', {value})->cursor();
30// Or limits
31Model::where('column', {value})->limit({n})->get();
32 // Get the first 10 green cars
33 $some_green_cars =
34 App\Models\Cars::where('color', 'green')->limit(10)->get();
35
1// Get All Where in condition
2$array = [1,2,3,4,5];
3ModelClassName::whereIn('columnName',$array)->get();