Only send inventory report to users if they have things checked out to them

This commit is contained in:
snipe 2018-09-07 03:08:32 -07:00
parent 451f4c3320
commit 827a86b2ef

View file

@ -41,13 +41,21 @@ class SendCurrentInventoryToUsers extends Command
public function handle()
{
$users = User::whereNull('deleted_at')->whereNotNull('email')->with('assets', 'accessories', 'consumables', 'licenses')->get();
$users = User::whereNull('deleted_at')->whereNotNull('email')->with('assets', 'accessories', 'licenses')->get();
$count = 0;
foreach ($users as $user) {
$this->info($user->email);
$user->notify((new CurrentInventory($user)));
if (($user->assets->count() > 0) || ($user->accessories->count() > 0) || ($user->licenses->count() > 0))
{
$count++;
$user->notify((new CurrentInventory($user)));
}
}
$this->info($count.' users notified.');
}
}