whereNotNull('email')->with('assets', 'accessories', 'licenses')->get(); $count = 0; foreach ($users as $user) { if (($user->assets->count() > 0) || ($user->accessories->count() > 0) || ($user->licenses->count() > 0) || ($user->consumables->count() > 0)) { $count++; $user->notify((new CurrentInventory($user))); } } $this->info($count.' users notified.'); } }