/** * Execute the console command. * * @return mixed */ public function handle() { $notifications = QueryHelper::getNotificationsToSend(); if (count($notifications > 0)) { foreach ($notifications as $notification) { $user = \App\User::find($notification->user_id); $group = \App\Group::find($notification->group_id); if ($user && $group) { $this->info('Checking if there is something to send to user:'******' (' . $user->email . ')' . ' for group:' . $group->id . ' (' . $group->name . ')'); $mailer = new AppMailer(); if ($mailer->sendNotificationEmail($group, $user)) { $this->info('Message sent'); } else { $this->info('Nothing sent'); } } } } }