In this tutorial you will learn about the Laravel where Day, Date, Month, Year, Time, Column and its application with practical example.
In this laravel eloquent query methods tutorial, I will show you how to use various laravel eloquents methods. In this tutorial you will learn about laravel eloquents methods like where, whereDate, whereRaw, whereMonth, whereYear, whereIn, whereNotIn, whereNull, whereNotNull, whereTime, havingRaw, whereBetween, whereNotBetween and laravel pluck.
- Laravel where Day, Date, Month, Year, Time, Column
- Laravel All Where Eloquent Queries Methods
- Where() Function :
- orWhere() Function :
- WhereBetween Function :
- WhereNotBetween Function :
- WhereIn() Function :
- WhereNull() Function :
- WhereNotNull() Function :
- WhereNotIn() Function :
- WhereDate() Function :
- WhereMonth() Function :
- WhereDay() Function :
- WhereYear() Function :
- WhereTime() Function :
- WhereColumn() Function :
- WhereRaw() Function :
- OrderBy Function :
- SelectRaw() Function :
- HavingRaw() Function :
- Laravel Pluck () Function:
- Laravel Delete () Functions:
Laravel where Day, Date, Month, Year, Time, Column
In this step by step tutorial I will demonstrate you use and application of laravel eloquents methods like where, whereDate, whereRaw, whereMonth, whereYear, whereIn, whereNotIn, whereNull, whereNotNull, whereTime, havingRaw, whereBetween, whereNotBetween and laravel pluck.
Laravel All Where Eloquent Queries Methods
Where() Function :
Below is simple example of laravel eloquent where() method:
1 2 3 4 5 |
DB::table('users') ->where('id', 1) ->get(); |
orWhere() Function :
Below is simple example of laravel eloquent orWhere() method:
1 2 3 4 5 6 7 |
DB::table('users') ->where('id', '>', 100) ->orWhere('name', 'w3adda') ->get(); |
WhereBetween Function :
Below is simple example of laravel eloquent WhereBetween() method:
1 2 3 |
DB::table('users') ->whereBetween('id', [1, 100])->get(); |
WhereNotBetween Function :
Below is simple example of laravel eloquent WhereNotBetween() method:
1 2 3 |
DB::table('users') ->whereNotBetween('id', [1, 100])->get(); |
WhereIn() Function :
Below is simple example of laravel eloquent WhereIn() method:
1 2 3 4 5 |
DB::table('users') ->whereIn('id', [1,2,2,3]) ->get(); |
WhereNull() Function :
Below is simple example of laravel eloquent WhereNull() method:
1 2 3 4 5 |
DB::table('users') ->whereNull('updated_at') ->get(); |
WhereNotNull() Function :
Below is simple example of laravel eloquent WhereNotNull() method:
1 2 3 4 5 |
DB::table('users') ->whereNotNull('updated_at') ->get(); |
WhereNotIn() Function :
Below is simple example of laravel eloquent WhereNotIn() method:
1 2 3 4 5 |
DB::table('users') ->whereNotIn('id', [1,2,2,3]) ->get(); |
WhereDate() Function :
Below is simple example of laravel eloquent WhereDate() method:
1 2 3 4 5 |
DB::table('users') ->whereDate('created_at', date('Y-m-d')) ->get(); |
WhereMonth() Function :
Below is simple example of laravel eloquent WhereMonth() method:
1 2 3 4 5 |
DB::table('users') ->whereMonth('created_at', '05') ->get(); |
WhereDay() Function :
Below is simple example of laravel eloquent WhereDay() method:
1 2 3 4 5 |
DB::table('users') ->whereDay('created_at', '05') ->get(); |
WhereYear() Function :
Below is simple example of laravel eloquent WhereYear() method:
1 2 3 4 5 |
DB::table('users') ->whereYear('created_at', '05') ->get(); |
WhereTime() Function :
Below is simple example of laravel eloquent WhereTime() method:
1 2 3 |
DB::table('users') ->whereTime('created_at', '=', '1:20:45') ->get(); |
WhereColumn() Function :
Below is simple example of laravel eloquent WhereColumn() method:
1 2 3 4 5 |
DB::table('users') ->whereColumn('first_name', 'last_name') ->get(); |
WhereRaw() Function :
Below is simple example of laravel eloquent WhereRaw() method:
1 2 3 4 5 |
DB::table('orders') ->whereRaw('price > IF(state = "TX", ?, 100)', [200]) ->get(); |
OrderBy Function :
Below is simple example of laravel eloquent OrderBy() method:
1 2 3 |
DB::table('users') ->orderBy('name', 'desc') ->get(); |
SelectRaw() Function :
Below is simple example of laravel eloquent SelectRaw() method:
1 2 3 4 5 |
DB::table('orders') ->selectRaw('price * ? as price_with_tax', [1.0825]) ->get(); |
HavingRaw() Function :
Below is simple example of laravel eloquent HavingRaw() method:
1 2 3 4 5 |
DB::table('orders') ->select('orders', DB::raw('SUM(price) as total_amount')) ->groupBy('orders') ->havingRaw('SUM(price) > ?', [2500]) ->get(); |
Laravel Pluck () Function:
Below is simple example of laravel eloquent pluck() method:
1 2 3 |
DB::table('users') ->where('id', 1) ->pluck('name'); |
Laravel Delete () Functions:
Below is simple example of laravel eloquent Delete() method:
1 2 3 |
DB::table('users') ->where('id', 1) ->delete(); |