| Server IP : 14.225.204.176 / Your IP : 216.73.216.6 Web Server : nginx/1.24.0 System : Linux nodejs-ybgk 6.8.0-40-generic #40-Ubuntu SMP PREEMPT_DYNAMIC Fri Jul 5 10:34:03 UTC 2024 x86_64 User : root ( 0) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/html/php/home-services/app/Http/Controllers/API/ |
Upload File : |
<?php
/*
* File name: WalletTransactionAPIController.php
* Last modified: 2021.08.11 at 01:13:13
* Author: SmarterVision - https://codecanyon.net/user/smartervision
* Copyright (c) 2021
*/
namespace App\Http\Controllers\API;
use App\Criteria\Wallets\WalletTransactionsOfUserCriteria;
use App\Http\Controllers\Controller;
use App\Repositories\WalletTransactionRepository;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use InfyOm\Generator\Criteria\LimitOffsetCriteria;
use Prettus\Repository\Criteria\RequestCriteria;
use Prettus\Repository\Exceptions\RepositoryException;
/**
* Class WalletTransactionController
* @package App\Http\Controllers\API
*/
class WalletTransactionAPIController extends Controller
{
/** @var WalletTransactionRepository */
private $walletTransactionRepository;
public function __construct(WalletTransactionRepository $walletTransactionRepo)
{
$this->walletTransactionRepository = $walletTransactionRepo;
}
/**
* Display a listing of the WalletTransaction.
* GET|HEAD /walletTransactions
*
* @param Request $request
* @return JsonResponse
*/
public function index(Request $request): JsonResponse
{
try {
$this->walletTransactionRepository->pushCriteria(new RequestCriteria($request));
$this->walletTransactionRepository->pushCriteria(new WalletTransactionsOfUserCriteria(auth()->id()));
$this->walletTransactionRepository->pushCriteria(new LimitOffsetCriteria($request));
} catch (RepositoryException $e) {
return $this->sendError($e->getMessage());
}
$walletTransactions = $this->walletTransactionRepository->orderBy('wallet_transactions.created_at', 'desc')->all();
return $this->sendResponse($walletTransactions->toArray(), 'Wallet Transactions retrieved successfully');
}
}