Laravel Simple Month Selection Laravel Simple Month Selection laravel laravel

Laravel Simple Month Selection


You could use the hide gem whereMonth:

DB::table("ordenes")    ->whereMonth('fecha', '=', '06')    ->get();

I highly recommend to you read the Builder.php source to search for another gems. :)https://github.com/laravel/framework/blob/4.2/src/Illuminate/Database/Query/Builder.php


You may try whereRaw method

$data = DB::table("ordenes")    // ...    ->whereRaw('MONTH(fecha) = ?', [06])    // ...    ->get();


You could use something like this

$users = Model::whereMonth('created_at', '12')->get();

https://laravel.com/docs/6.x/queries#where-clauses