HEX
Server: nginx/1.28.1
System: Linux 10-41-63-61 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User: www (1001)
PHP: 7.4.33
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/www.shooperm.com/Modules/Wallet/Repositories/WithdrawRequestRepository.php
<?php

namespace Modules\Wallet\Repositories;
use Modules\Wallet\Entities\WalletBalance;
use Modules\Account\Repositories\TransactionRepository;
use Modules\Account\Entities\Transaction;
use App\Models\User;
use App\Traits\SendMail;
use App\Traits\Accounts;
use App\Traits\Notification;
use Carbon\Carbon;
use Modules\GeneralSetting\Entities\EmailTemplateType;

class WithdrawRequestRepository
{
    use SendMail, Accounts,Notification;

    public function getAll()
    {
        return WalletBalance::with('user','user.SellerBankAccount')->where('type', 'Withdraw')->latest();
    }

    public function getMyAll()
    {
        return WalletBalance::with('user')->where('user_id', auth()->user()->id)->where('type', 'Withdraw')->latest();
    }

    public function findWidrawRequestById($id){
        return WalletBalance::findOrFail($id);
    }

    public function withdrawRequestStore($data)
    {
        WalletBalance::create([
            'user_id' => auth()->user()->id,
            'type' => 'Withdraw',
            'amount' => $data['amount'],
            'payment_method' => 7,
            'txn_id' => "None",
            'status' => 0,
        ]);

         // Send Notification
         $this->notificationUrl = route('wallet.withdraw_requests');
         $this->typeId = EmailTemplateType::where('type', 'withdraw_request_email_template')->first()->id;
         $user1 = User::where('role_id',1)->first();
         $user2 = User::where('role_id',2)->first();
         $this->notificationSend("Seller payout Request", $user1->id);
         $this->notificationSend("Seller payout Request", $user2->id);
    }

    public function withdrawRequestUpdate(array $data)
    {
        WalletBalance::findOrFail($data['id'])->update([
            'amount' => $data['amount'],
        ]);
    }

    public function withdrawRequestStatusUpdate($data, $id)
    {
        $wallet_balance = WalletBalance::findOrFail($id);
        $wallet_balance->update([
            'status' => $data['status'],
        ]);
        $notificationUrl = route('my-wallet.withdraw_index');
        $this->notificationUrl = $notificationUrl;
        $this->typeId = EmailTemplateType::where('type','wallet_email_template')->first()->id;//wallet email templete typeId
        if ($data['status'] == 1) {
            $transactionRepo = new TransactionRepository(new Transaction);
            $defaultSellerAccount = $this->defaultSellerAccount();
            $transactionRepo->makeTransaction("Money Withdraw By Seller", "out", $wallet_balance->GatewayName, "sales_expense", $defaultSellerAccount, "Product Sale GST", $wallet_balance, $wallet_balance->amount, Carbon::now()->format('Y-m-d'), auth()->id(), null, null);

            $this->notificationSend("Withdraw request approve",$wallet_balance->user_id);
        }else{
            $this->notificationSend("Withdraw request declined",$wallet_balance->user_id);
        }
    }

    public function delete($id)
    {
        //
    }
}