Usages

Payment is polymorphic, hence with the use of trait HasPayable can be used with any model.

use Pratiksh\Payable\Traits\HasPayable;

class Product extends Model
{
    use  HasPayable;
}

HasPayable Available methods

payments

returns Illuminate\Database\Eloquent\Relations\MorphMany

Retrieves the model payments record. payments is polymorphic relation

$product->payments;

pay

parameter

  • amount (float) : Payment amount to be registered

returns

  • Pratiksh\Payable\Models\Payment

$product->pay(100)

modifyPay

parameter

  • payment(Pratiksh\Payable\Models\Payment) : Payment instance to be updated

  • amount (float) : Payment amount to be updated

returns

  • Pratiksh\Payable\Models\Payment

$product->modifyPay($product->payments()->latest()->first(),200) // Modified from 100 to 200

Last updated