Laravel cancel model update
Laravel cancel model update
<?php
namespace App\Observers\Payments;
use App\Facades\Payments\MemberBalanceService;
use App\Models\Payments\MemberPayment;
use Exception;
class MemberPaymentObserver
{
/**
* * creating.
*
* @param mixed $memberPayment
* @return void
*/
public function creating(MemberPayment $memberPayment)
{
//** Check amount member payment not enought
//** $memberPayment->paymnet_amount!==$memberPayment->servicePackage->totalPrice
if (! ($memberPayment->paymnet_amount >= $memberPayment->servicePackage->totalPrice)) {
throw new Exception('Payment amount not enought for service package');
return false;
}
}
}