The Rise of Contactless Payments:...
In recent years, contactless payments have surged in popularity, driven...
<?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);
}
}
Blog Section
Dive into our blog to explore the cutting-edge trends in digital payments and NFC technology. Stay updated on the innovations that are revolutionizing transactions, boosting security, and making payments quicker and more convenient. Learn how these advancements are shaping the future of financial interactions and driving the global transition towards a cashless world.
In recent years, contactless payments have surged in popularity, driven...
As digital transactions proliferate, ensuring robust payment security is more critical than ever. Two foundational...
Digital wallets have fundamentally transformed how we manage money, offering a streamlined, secure, and highly...