Added achievement data
This commit is contained in:
1 parent
f6d5b97784
commit
14aed7bf6e
18 files changed
+950
-6
No files matched your search
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Models\UserFlight;
|
||||
|
||||
class FlightObserver
|
||||
{
|
||||
/**
|
||||
* Recalculate after a flight is created.
|
||||
*/
|
||||
public function created(UserFlight $flight): void
|
||||
{
|
||||
$flight->user->calculateAchievements();
|
||||
}
|
||||
|
||||
/**
|
||||
* Recalculate after a flight is updated.
|
||||
* Cabin class, flight type, airline, etc. may have changed,
|
||||
* which could unlock or revoke achievements.
|
||||
*/
|
||||
public function updated(UserFlight $flight): void
|
||||
{
|
||||
$flight->user->calculateAchievements();
|
||||
}
|
||||
|
||||
/**
|
||||
* Recalculate after a flight is deleted.
|
||||
* Previously earned achievements may no longer be valid.
|
||||
*/
|
||||
public function deleted(UserFlight $flight): void
|
||||
{
|
||||
$flight->user->calculateAchievements();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user