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