Karabah
Karabah

Reputation: 249

How to use array for ->whereMonth Laravel?

Is it possible to use array as value for function DB:

->whereMonth($month);

Like this: ->whereMonth([01, 02, 12]);

Upvotes: 1

Views: 3402

Answers (1)

Devon Bessemer
Devon Bessemer

Reputation: 35337

whereMonth does not support arrays, and the first argument is the column name, not the value.

https://laravel.com/api/5.3/Illuminate/Database/Query/Builder.html#method_whereMonth

You can instead use whereIn with a raw expression:

->whereIn(DB::raw('MONTH(column)'), [1,2,3])

Upvotes: 5

Related Questions