phpvms/app/Listeners/AwardListener.php

33 lines
710 B
PHP
Raw Normal View History

<?php
namespace App\Listeners;
use App\Events\UserStatsChanged;
use App\Interfaces\Listener;
use App\Models\Award;
/**
* Look for and run any of the award classes. Don't modify this.
* See the documentation on creating awards:
2018-08-27 00:40:04 +08:00
*
* @url http://docs.phpvms.net/customizing/awards
*/
class AwardListener extends Listener
{
/**
* Call all of the awards
2018-08-27 00:40:04 +08:00
*
* @param UserStatsChanged $event
*/
public function handle(UserStatsChanged $event): void
{
$awards = Award::all();
foreach ($awards as $award) {
$klass = $award->getReference($award, $event->user);
if ($klass) {
$klass->handle();
}
}
}
}