Date format Query in Laravel

Solution:

Use raw statement instead. For example:

$user = User::select(DB::raw('count(*) as user_count, status'))->where('status', '=', 'active');

By the way actually, Laravel has mutator for field with DateTime type. So you can select it as normal and format it later. Example;

$user = User::find(2);
$date = $user->created_at->format('d M Y'); // you can display it with any format you want with this way.

More information read the official documentation and this