Skip to main content

Command Palette

Search for a command to run...

Laravel cancel model update

Published
1 min readView as Markdown

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;
        }
    }
}

More from this blog

Khang Nguyen

119 posts