21 lines
517 B
PHP
Executable File
21 lines
517 B
PHP
Executable File
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Observers;
|
|
|
|
use App\Models\Wallet;
|
|
use App\Notifications\WalletBalanceLowNotification;
|
|
|
|
class WalletObserver
|
|
{
|
|
public function updated(Wallet $wallet)
|
|
{
|
|
// todo mettre le montant dans un fichier de config / une constante ou autre
|
|
// /!\ balance is in cents
|
|
if ($wallet->getOriginal('balance') > $wallet->balance && $wallet->balance < 1000) {
|
|
$wallet->user->notify(new WalletBalanceLowNotification($wallet));
|
|
}
|
|
}
|
|
}
|