getCurrentNotificationId(); $this->info(sprintf('Notification id = %s', $notification_id)); } catch (WrongHourException $e) { $this->error($e->getMessage()); exit; } $users = User::where('notification_hour', '=', $notification_id) ->where('email_verified_at', '!=', null) ->whereNotExists(function($query) { $query->select() ->from('posts') ->whereRaw('posts.user_id = users.id') ->whereDate('date_post', date('Y-m-d')); }) ->get(); foreach ($users as $user) { Mail::to($user)->queue(new DailyNotification($user)); } } }