phpvms/app/Listeners/AwardListener.php

33 lines
709 B
PHP
Raw Normal View History

<?php
namespace App\Listeners;
use App\Contracts\Listener;
2019-07-16 03:51:35 +08:00
use App\Events\UserStatsChanged;
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();
}
}
}
}