phpvms/app/Listeners/AwardListener.php

29 lines
557 B
PHP
Raw Normal View History

<?php
namespace App\Listeners;
use App\Events\UserStatsChanged;
use App\Models\Award;
/**
* Look for and run any of the award classes
* @package App\Listeners
*/
class AwardListener
{
/**
* Call all of the awards
* @param UserStatsChanged $event
*/
public function handle(UserStatsChanged $event)
{
$awards = Award::all();
foreach($awards as $award) {
$klass = $award->getReference($award, $event->user);
if($klass) {
$klass->handle();
}
}
}
}