<?php
namespace App\Http\Controllers\User;
use App\Constants\PaymentGatewayConst;
use App\Models\Card;
use App\Models\UserWallet;
use App\Models\Transaction;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Helpers\Response;
use App\Models\User;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Validator;
class DashboardController extends Controller
{
/**
* Method for view index page
*/
public function index(){
$page_title = "Dashboard";
$user_wallet = UserWallet::with(['currency'])->auth()->first();
$card_payments = Card::auth()->where('default',true)->first();
$total_cards = Card::auth()->count();
$total_transactions = Transaction::auth()->count();
$transactions = Transaction::with(['card_method','payment_gateway'])->auth()
->orderBy('id','desc')->latest()->take(3)->get();
$add_money = Transaction::auth()->where('type',PaymentGatewayConst::ADDMONEY)->count();
$transfer_money = Transaction::auth()->where('type',PaymentGatewayConst::TYPETRANSFERMONEY)->count();
$card_payment = Transaction::auth()->where('type',PaymentGatewayConst::CARD_PAYMENT)->count();
return view('user.dashboard',compact(
"page_title",
"user_wallet",
"card_payments",
'total_cards',
'transactions',
'total_transactions',
'add_money',
'transfer_money',
'card_payment'
));
}
public function getTransactionsByCard($id){
$transactions = Transaction::auth()->where('card_id', $id)->latest()->get();
return response()->json($transactions);
}
/**
* Method for user logout method
* @param Illuminate\Http\Request $request
*/
public function logout(Request $request) {
Auth::logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
return redirect()->route('user.login');
}
/**
* Method for check wether user is valid or not
* @param Illuminate\Http\Request $request
*/
public function checkValidUser(Request $request){
$validator = Validator::make($request->all(),[
'email' => 'required|email'
]);
if($validator->fails()) return Response::validation(['error' => $validator->errors()->all()]);
$validated = $validator->validate();
$exist['data'] = User::where('email',$validated['email'])->first();
$user = auth()->user();
if(@$exist['data'] && $user->email == @$exist['data']->email){
return response()->json(['own'=>__("Can't transfer to your own account.")]);
}
return response($exist);
}
}
Service Section
Discover how our services are designed to enhance your NFC Pay experience with convenience, security, and innovative solutions. From managing transactions to secure payments, we are dedicated to providing seamless support every step of the way.
Easily save your credit and debit card details within our app for quick and secure transactions. This feature ensures that your payment information is protected with advanced encryption and can be used for future purchases with just a tap.
Transfer funds quickly and securely between users with our streamlined money transfer service. Simply select the recipient, enter the amount, and authorize the transaction for instant, hassle-free transfers.
Activate your merchant account effortlessly to start receiving payments. Our intuitive setup process ensures that you can begin accepting transactions smoothly, helping your business thrive with minimal setup time.
Keep track of all your transactions in real time through our app. Monitor payment statuses, view transaction history, and manage your account efficiently, ensuring complete control over your financial activities.
Our dedicated support team is available to assist you with any queries or issues. Whether you need help with setting up your account or resolving transaction-related questions, we’re here to provide prompt and reliable assistance.