My question is about formatting queries not working with data after fetching them.
Your reply is correct in most cases but in rare cases (especially resource considerate) selecting broad ranges of data and sorting them afterwards is just not a way to go.
@ARDF16 - Not sure if I understood you correctly, if so, then you can add a method to your model
class User extends Model
{
public function getCreatedMonthAttribute()
{
return $this->created_at;
}
}
// ....
$user = User::first();
$user->created_month;
The issue here is that in order to fetch grouped by formated date columns directly from database you are forced to use raw queries which are database specific.
I'm looking for solution that uses eloquent query builder build in functions instead.