Proven Expertise
Our team brings years of experience in the digital payments industry to provide reliable services.
<?php
namespace App\Http\Controllers\User;
use Exception;
use App\Models\User;
use App\Mail\UserRegister;
use Illuminate\Support\Str;
use Jenssegers\Agent\Agent;
use App\Models\UserLoginLog;
use Illuminate\Http\Request;
use App\Mail\UserConfirmMail;
use Illuminate\Support\Carbon;
use App\Models\UserPasswordReset;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\Controller;
use App\Mail\UserForgotPasswordCode;
use App\Models\UserWallet;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Validator;
use App\Providers\Admin\BasicSettingsProvider;
class UserController extends Controller
{
public $basic_settings;
public function __construct()
{
$this->basic_settings = BasicSettingsProvider::get();
}
protected function createLoginLogs($admin)
{
$client_ip = request()->ip() ?? false;
$location = geoip()->getLocation($client_ip);
$agent = new Agent();
$mac = "";
$data = [
'user_id' => $admin->id,
'ip' => $client_ip,
'mac' => $mac,
'city' => $location['city'] ?? "",
'country' => $location['country'] ?? "",
'longitude' => $location['lon'] ?? "",
'latitude' => $location['lat'] ?? "",
'timezone' => $location['timezone'] ?? "",
'browser' => $agent->browser() ?? "",
'os' => $agent->platform() ?? "",
'created_at' => date('d-m-Y') ?? ""
];
try {
UserLoginLog::create($data);
} catch (Exception $e) {
info($e);
return false;
}
}
public function showLoginForm(Request $request)
{
if ($request->isMethod("POST")) {
$data = $request->all();
$activeCurrency = DB::table('currencies')->select('code', 'id', 'country', 'type')->where('status', '=', 1)->get();
$this->validate($request, [
'username' => 'required',
'password' => 'required',
]);
$userCheck = User::where(function ($query) use ($data) {
$query->where('email', $data['username']);
})->orWhere('username', $data['username'])->active()->first();
if (isset($userCheck) && $userCheck->status == 0) {
return redirect()->back()->with(['error' => ['Your account is not activated check mail inbox/spam.']]);
}
$fieldType = filter_var($request->username, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
if (auth()->attempt(array($fieldType => $data['username'], 'password' => $data['password']))) {
$user = Auth::user();
// Create Login Logs
$this->createLoginLogs($user);
// Create wallet for user
foreach ($activeCurrency as $currency) {
$walletCheck = UserWallet::where('user_id', $user->id)->where('currency_id', $currency->id)->count();
if ($walletCheck == 0) {
$wallet = new UserWallet();
$wallet->user_id = auth()->user()->id;
$wallet->currency_id = $currency->id;
$wallet->balance = 0;
$wallet->save();
}
}
return redirect()->route('user.dashboard');
} else {
return redirect()->route('user.login')
->with(['error' => ['Email-Address And Password Are Wrong.']]);
}
}
return view('frontend.pages.auth.user_login');
}
public function checkCurrentUsername(Request $request)
{
$data = $request->all();
$checkUserName = User::where('username', $data['username_input'])->count();
if ($checkUserName > 0) {
echo "false";
} else {
echo "true";
}
}
public function checkEmail(Request $request)
{
$data = $request->all();
$mailCount = User::where('email', $data['email'])->count();
if ($mailCount > 0) {
return "false";
} else {
return "true";
}
}
public function userRegistration(Request $request)
{
$page_title = "Register Information";
if ($request->isMethod('POST')) {
$data = $request->all();
$rules = [
'first_name' => 'required',
'email' => 'required|regex:/(.+)@(.+)\.(.+)/i|email|unique:users',
'username' => 'required|string|regex:/\w*$/|max:255|unique:users,username',
'password' => 'required|string|min:6',
'accept' => 'required',
];
//Validation message
$customMessage = [
'first_name.required' => 'First name is required',
'email.required' => 'Email is required',
'password.required' => 'Password is required',
'accept.required' => 'Please Accept Terms Of Use , Privacy Policy & Warning'
];
$validator = Validator::make($data, $rules, $customMessage);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator);
}
try {
$user = new User();
$user->username = Str::lower($data['username']);
$user->first_name = $data['first_name'];
$user->last_name = $data['last_name'];
$user->email = $data['email'];
$user->password = Hash::make($data['password']);
if (isset($data['accept'])) {
$user->accept = $data['accept'];
}
if ($this->basic_settings->email_verification == 0) {
$user->status = 1;
}
$user->save();
if (isset($this->basic_settings) && $this->basic_settings->email_verification == 1) {
Mail::to($data['email'])->send(new UserRegister($data['first_name'], base64_encode($data['email'])));
return redirect()->route('user.login')->with(['success' => ['Please check your email to activate your account.']]);
} else {
return redirect()->route('user.login')->with(['success' => ['Registration successfull.']]);
}
} catch (Exception $e) {
info($e);
return redirect()->back()->with(['error' => ['Unable to save this action.']]);
}
}
return view('frontend.pages.auth.register', compact('page_title'));
}
public function confirmAccount($email)
{
Session::forget('error');
Session::forget('success');
//Decode user email
$email = base64_decode($email);
//Check user email exist
$vendorCount = User::where('email', $email)->count();
if ($vendorCount > 0) {
//User email alrady activated or not
$userDetails = User::where('email', $email)->first();
if ($userDetails->status == 1) {
Session::put('error');
return redirect()->route('user.login')->with(['error' => 'Your email account is already activated! Please login']);
} else {
User::where('email', $email)->update(['status' => 1, 'email_verified' => 1, 'email_verified_at' => Carbon::now()]);
try {
Mail::to($email)->send(new UserConfirmMail($userDetails->first_name, $userDetails->email));
} catch (\Exception $ex) {
info($ex);
}
return redirect()->route('user.login')->with(['success' => ['Your email account is activated! You can login now and update your necessary information to upload product']]);
}
} else {
abort(404);
}
}
public function forgotPasswordCodeGenerate(Request $request)
{
if ($request->isMethod("POST")) {
$data = $request->all();
$userCheck = DB::table('users')->select('email', 'id', 'username')->where('email', '=', $data['email'])->first();
if (isset($userCheck)) {
$pass_r = new UserPasswordReset();
$pass_r->email = $data['email'];
$pass_r->user_id = $userCheck->id;
$pass_r->password_reset_code = rand(1212, 9090);
$pass_r->save();
$lastId = DB::getPdo()->lastInsertId();
$pwdCode = DB::table('user_password_resets')->where('email', '=', $data['email'])->where('id', $lastId)->pluck('password_reset_code')->first();
Mail::to($data['email'])->send(new UserForgotPasswordCode($userCheck->username, $pwdCode));
return redirect('user/enter/pwd/reset/code')->with(['success' => ['Please check email inbox/spam']]);
} else {
return redirect()->route('user.login')->with(['error' => ['Email not found']]);
}
}
}
public function enterPwdResetCode(Request $request)
{
if ($request->isMethod("POST")) {
$data = $request->all();
$userCheck = UserPasswordReset::with('user')->where('password_reset_code', '=', $data['password_reset_code'])->first();
$userData = json_decode(json_encode($userCheck), true);
if (isset($userData)) {
return view('frontend.pages.auth.set_new_password', compact('userData'));
} else {
return redirect()->back()->with(['error' => ['Code not found']]);
}
}
return view('frontend.pages.auth.pwd_reset_code');
}
public function setNewPassword(Request $request, $username)
{
$user = User::where('username', $username)->firstOrFail();
if ($request->isMethod('POST')) {
$data = $request->all();
$rules = [
'new_password' => 'required|string|min:6',
];
//Validation message
$customMessage = [
'new_password.required' => 'Password is required',
];
$validator = Validator::make($data, $rules, $customMessage);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator);
}
$user->first_name = $user->first_name;
$user->username = $data['username'];
$user->email = $data['email'];
$user->password = bcrypt($data['new_password']);
$user->update();
UserPasswordReset::where('user_id', $user->id)->delete();
return redirect('/user/login')->with(['success' => ['Password Changed successfully login please!']]);
} else {
abort(404, 'Whatever you were looking for, look somewhere else');
}
}
}
How it Works
Getting started with NFC Pay is simple and quick. Register your account, add your cards, and you're ready to make payments in no time. Whether you're paying at a store, sending money to a friend, or managing your merchant transactions, NFC Pay makes it easy and secure.
Download the NFC Pay app and sign up with your email or phone number. Complete the registration process by verifying your identity, and set up your secure PIN to protect your account.
Link your debit or credit cards to your NFC Pay wallet. Simply scan your card or enter the details manually, and you’re set to load funds, shop, and pay with ease.
To pay, simply tap your phone or scan the QR code at checkout. You can also transfer money to other users with a few taps. Enjoy fast, contactless payments with top-notch security.
Security System
NFC Pay prioritizes your security with advanced features that safeguard every transaction. From SMS or email verification to end-to-end encryption, we've implemented robust measures to ensure your data is always protected. Our security systems are designed to prevent unauthorized access and provide you with a safe and reliable payment experience.
Receive instant alerts for every transaction to keep track of your account activities.
Verify your identity through our Know Your Customer process to prevent fraud and enhance security.
Dramatically supply transparent backward deliverables before caward comp internal or "organic" sources.
All your data and transactions are encrypted, ensuring that your sensitive information remains private.
Monitor unusual activity patterns to detect and prevent suspicious behavior in real-time.
Why Choice Us
With NFC Pay, you get a trusted platform backed by proven expertise and a commitment to quality. We put our customers first, offering innovative solutions tailored to your needs, ensuring every transaction is secure, swift, and seamless.
Our team brings years of experience in the digital payments industry to provide reliable services.
We prioritize excellence, ensuring that every aspect of our platform meets the highest standards.
Your needs drive our solutions, and we are dedicated to delivering a superior user experience.
We continuously evolve, integrating the latest technologies to enhance your payment experience.
Testimonial Section
Hear from our users who trust NFC Pay for their everyday transactions. Our commitment to security, ease of use, and exceptional service shines through in their experiences. See why our clients choose NFC Pay for their payment needs and how it has transformed the way they manage their finances.
App Section
Unlock the full potential of NFC Pay by downloading our app, designed to bring secure, swift, and smart transactions to your fingertips. Whether you're paying at a store, transferring money to friends, or managing your business payments, the NFC Pay app makes it effortless. Available on both iOS and Android, it's your all-in-one solution for convenient and reliable digital payments. Download now and experience the future of payments!