diff --git a/app/Modules/VisaMasterPaymentOrder/Models/VisaMasterPaymentOrder.php b/app/Modules/VisaMasterPaymentOrder/Models/VisaMasterPaymentOrder.php index 2fc0254..ee3c34d 100644 --- a/app/Modules/VisaMasterPaymentOrder/Models/VisaMasterPaymentOrder.php +++ b/app/Modules/VisaMasterPaymentOrder/Models/VisaMasterPaymentOrder.php @@ -3,7 +3,9 @@ namespace App\Modules\VisaMasterPaymentOrder\Models; use App\Models\Branch\Branch; +use App\Models\User; use App\Repos\Order\Loan\LoanOrderRepo; +use App\Repos\Order\OrderRepo; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Spatie\MediaLibrary\HasMedia; @@ -36,6 +38,27 @@ class VisaMasterPaymentOrder extends Model implements HasMedia 'payment_reciever' => 'array', ]; + /** + * The "booted" method of the model. + */ + protected static function booted(): void + { + static::updated(function ($visaMasterPaymentOrder) { + if ($visaMasterPaymentOrder->status === OrderRepo::COMPLETED) { + $user = User::find($visaMasterPaymentOrder->user_id); + + if (! $user) { + return; + } + + sendSMS( + phone: $user->phone, + message: $visaMasterPaymentOrder->unique_id . 'belgili sargydyňyz kanagatlandyryldy. Banka ýüztutmagyňyzy Sizden haýyş edýäris.' + ); + } + }); + } + /** * Media collections */