Taslim
Taslim

Reputation: 17

Laravel 5.4 whereDate in Eloquent

How to use whereMonth, whereDate in Eloquent ORM? (I know it can in DB query). Im using 5.4

Upvotes: 0

Views: 918

Answers (1)

Suresh Velusamy
Suresh Velusamy

Reputation: 2398

You can use all the methods from DB query in Eloquent models, Check the following samples you can easily capture it. Both the samples, produce the same result

Using query builder

$users = DB::table('users')
                ->whereDate('created_at', '2016-12-31')
                ->get();

Using model

$users = Users::whereDate('created_at', '2016-12-31')
                ->get();

Upvotes: 2

Related Questions