Edit File: PayProcess.php
<?php namespace App\Services\Payment; use App\Enums\WalletTransaction; use App\Models\Admin; use App\Models\Wallet; use App\Traits\ResponseTrait; class PayProcess { use ResponseTrait; public function payAmountToAdmin($amount) { $toWallet = Wallet::firstOrCreate(['walletable_type' => Admin::class, 'walletable_id' => 1]); $toWallet->increment('balance', $amount); $toWallet->transactions()->create([ 'amount' => $amount, 'type' => WalletTransaction::CHARGE, ]); return true; } public function cutAmountFromAdminForSettlement($amount) { $fromWallet = Wallet::firstOrCreate(['walletable_type' => Admin::class, 'walletable_id' => 1]); $fromWallet->decrement('balance', $amount); $fromWallet->transactions()->create([ 'amount' => $amount, 'type' => WalletTransaction::DEBT, ]); return true; } }
Back to File Manager